aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-06-26 11:18:13 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-06-26 11:18:13 +1200
commit6ed7e3c18378f627488f20d6af00de1a89fe5042 (patch)
treefbacf8e72729db38089c293b29fc79023aeeb327 /vim
parent764c5c260b114750fd157f3839e48ea2cb0aa677 (diff)
parent71c0add471fdb6400ebc8b48686358dd6d118b05 (diff)
downloaddotfiles-6ed7e3c18378f627488f20d6af00de1a89fe5042.tar.gz
dotfiles-6ed7e3c18378f627488f20d6af00de1a89fe5042.zip
Merge branch 'release/v1.6.0'v1.6.0
* release/v1.6.0: Bump VERSION Update clear_local_maps.vim plugin Clear away VimL mapping rubbish Refactor filetype-specific .vimrc material Remap normal J only if loading plugins
Diffstat (limited to 'vim')
-rw-r--r--vim/after/ftplugin/vim/clear_maps.vim37
m---------vim/bundle/clear_local_maps0
-rw-r--r--vim/filemap.vim51
-rw-r--r--vim/filetype.vim24
-rw-r--r--vim/vimrc67
5 files changed, 115 insertions, 64 deletions
diff --git a/vim/after/ftplugin/vim/clear_maps.vim b/vim/after/ftplugin/vim/clear_maps.vim
new file mode 100644
index 00000000..a84ca4b9
--- /dev/null
+++ b/vim/after/ftplugin/vim/clear_maps.vim
@@ -0,0 +1,37 @@
+" vim/clear_maps.vim: Fix clearing buffer-local vim maps that the core
+" ftplugin leaves in place
+
+" Don't load if running compatible or too old
+if &compatible || v:version < 700
+ finish
+endif
+
+" Don't load if already loaded
+if exists('b:did_ftplugin_vim_lint')
+ finish
+endif
+
+" Don't load if the mappings probably weren't loaded in the first place
+if exists('g:no_plugin_maps') || exists('g:no_vim_maps')
+ finish
+endif
+
+" Flag as loaded
+let b:did_ftplugin_vim_clear_maps = 1
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|unlet b:did_ftplugin_vim_clear_maps'
+
+" Add undo commands
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|silent! nunmap <buffer> [['
+ \ . '|silent! vunmap <buffer> [['
+ \ . '|silent! nunmap <buffer> ]]'
+ \ . '|silent! vunmap <buffer> ]]'
+ \ . '|silent! nunmap <buffer> []'
+ \ . '|silent! vunmap <buffer> []'
+ \ . '|silent! nunmap <buffer> ]['
+ \ . '|silent! vunmap <buffer> ]['
+ \ . '|silent! nunmap <buffer> ]"'
+ \ . '|silent! vunmap <buffer> ]"'
+ \ . '|silent! nunmap <buffer> ["'
+ \ . '|silent! vunmap <buffer> ["'
diff --git a/vim/bundle/clear_local_maps b/vim/bundle/clear_local_maps
-Subproject b1038f42ef051f2829464b60d3a4aa13f3020d3
+Subproject 61fb4c0926d4f26014e1765bf6d22c1d968c6f8
diff --git a/vim/filemap.vim b/vim/filemap.vim
new file mode 100644
index 00000000..bbbf1955
--- /dev/null
+++ b/vim/filemap.vim
@@ -0,0 +1,51 @@
+" Filetype-specific mappings
+if &compatible || v:version < 700 || !has('autocmd')
+ finish
+endif
+
+" No 'loaded' guard; this file is an extension of our .vimrc, and we do want
+" to reload it if the .vimrc is re-sourced.
+
+" Set up filetype mapping hooks
+augroup filetypemap
+ autocmd!
+
+ " Clear existing local leader maps if possible
+ autocmd FileType *
+ \ silent! call clear_local_maps#Clear()
+
+ " Diff: prune sections
+ autocmd FileType diff
+ \ nmap <buffer> <LocalLeader>p <Plug>DiffPrune
+ \|xmap <buffer> <LocalLeader>p <Plug>DiffPrune
+
+ " HTML: lint, URL-to-link, tidy
+ autocmd FileType html
+ \ nmap <buffer> <LocalLeader>l <Plug>HtmlLint
+ \|nmap <buffer> <LocalLeader>r <Plug>HtmlUrlLink
+ \|nmap <buffer> <LocalLeader>t <Plug>HtmlTidy
+
+ " Perl: check, lint, and tidy
+ autocmd FileType perl
+ \ nmap <buffer> <LocalLeader>c <Plug>PerlCheck
+ \|nmap <buffer> <LocalLeader>l <Plug>PerlLint
+ \|nmap <buffer> <LocalLeader>t <Plug>PerlTidy
+
+ " PHP: check
+ autocmd FileType php
+ \ nmap <buffer> <LocalLeader>c <Plug>PhpCheck
+
+ " Shell: check and lint
+ autocmd FileType sh
+ \ nmap <buffer> <LocalLeader>c <Plug>ShCheck
+ \|nmap <buffer> <LocalLeader>l <Plug>ShLint
+
+ " VimL: lint
+ autocmd FileType vim
+ \ nmap <buffer> <LocalLeader>l <Plug>VimLint
+
+ " Zsh: check
+ autocmd FileType zsh
+ \ nmap <buffer> <LocalLeader>c <Plug>ZshCheck
+
+augroup END
diff --git a/vim/filetype.vim b/vim/filetype.vim
index 69847ba7..66b26455 100644
--- a/vim/filetype.vim
+++ b/vim/filetype.vim
@@ -324,15 +324,15 @@ augroup filetypedetect
\,bash_logout
\,bash_profile
\,bashrc
- \ let b:is_bash = 1
- \ | setfiletype sh
+ \ let b:is_bash = 1
+ \|setfiletype sh
" Korn shell
autocmd BufNewFile,BufRead
\ ?*.ksh
\,.kshrc
\,kshrc
- \ let b:is_kornshell = 1
- \ | setfiletype sh
+ \ let b:is_kornshell = 1
+ \|setfiletype sh
" POSIX/Bourne shell
autocmd BufNewFile,BufRead
\ ?*.sh
@@ -347,8 +347,8 @@ augroup filetypedetect
\,shinit
\,shrc
\,xinitrc
- \ let b:is_posix = 1
- \ | setfiletype sh
+ \ let b:is_posix = 1
+ \|setfiletype sh
" sed files
autocmd BufNewFile,BufRead
\ ?*.sed
@@ -495,17 +495,17 @@ augroup filetypedetect
" been found; strip temporary extension and re-run
autocmd BufNewFile,BufRead
\ /var/tmp/?*.????????
- \ if !did_filetype()
- \ | call s:StripRepeat()
- \ | endif
+ \ if !did_filetype()
+ \| call s:StripRepeat()
+ \|endif
" If we *still* don't have a filetype, run the scripts.vim file that will
" examine actual file contents--but only the first one; don't load the
" system one at all
autocmd BufNewFile,BufRead,StdinReadPost
\ *
- \ if !did_filetype()
- \ | runtime scripts.vim
- \ | endif
+ \ if !did_filetype()
+ \| runtime scripts.vim
+ \|endif
augroup END
diff --git a/vim/vimrc b/vim/vimrc
index 2e90ecbe..72106b0a 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -4,9 +4,11 @@
" own without the accompanying plugins to which it refers near the end of this
" file, but you'll get errors for some of the leader maps, for example.
-" Load filetype settings and plugins
+" Load filetype settings, plugins, and maps
if has('autocmd')
+ let g:maplocalleader = '_'
filetype plugin indent on
+ runtime filemap.vim
endif
" Options dependent on the syntax feature
@@ -200,9 +202,10 @@ nnoremap ]t :<C-U>tabnext<CR>
nmap [<Space> <Plug>PutBlankLinesAbove
nmap ]<Space> <Plug>PutBlankLinesBelow
-" Remap normal J to stay in place while joining lines; fall back to default
-nnoremap <Plug>FixedJoin J
-nmap J <Plug>FixedJoin
+" Remap normal J to stay in place while joining lines
+if &loadplugins
+ nmap J <Plug>FixedJoin
+endif
" Remap normal Y to yank to end of line (consistent with C, D)
nnoremap Y y$
@@ -270,56 +273,15 @@ nmap <Leader>x <Plug>StripTrailingWhitespace
" \z sets NZ English spelling (compare \u)
nnoremap \z :<C-U>setlocal spelllang=en_nz spelllang?<CR>
-" Use underscore for a local leader, for any plugins that use the variable
-if 1
- let g:maplocalleader = '_'
-endif
-
-" Filetype-specific mappings
-if has('autocmd') && v:version >= 700
- augroup vimrc_filetype_mappings
- autocmd!
-
- " Clear existing local leader maps
- autocmd FileType * silent! call clear_local_maps#Clear()
-
- " Diff: prune sections
- autocmd FileType diff nmap <buffer> <LocalLeader>p <Plug>DiffPrune
- autocmd FileType diff xmap <buffer> <LocalLeader>p <Plug>DiffPrune
-
- " HTML: lint, URL-to-link, tidy
- autocmd FileType html nmap <buffer> <LocalLeader>l <Plug>HtmlLint
- autocmd FileType html nmap <buffer> <LocalLeader>r <Plug>HtmlUrlLink
- autocmd FileType html nmap <buffer> <LocalLeader>t <Plug>HtmlTidy
-
- " Perl: check, lint, and tidy
- autocmd FileType perl nmap <buffer> <LocalLeader>c <Plug>PerlCheck
- autocmd FileType perl nmap <buffer> <LocalLeader>l <Plug>PerlLint
- autocmd FileType perl nmap <buffer> <LocalLeader>t <Plug>PerlTidy
+" Settings for plugins
+if &loadplugins
- " PHP: check
- autocmd FileType php nmap <buffer> <LocalLeader>c <Plug>PhpCheck
-
- " Shell: check and lint
- autocmd FileType sh nmap <buffer> <LocalLeader>c <Plug>ShCheck
- autocmd FileType sh nmap <buffer> <LocalLeader>l <Plug>ShLint
-
- " VimL: lint
- autocmd FileType vim nmap <buffer> <LocalLeader>l <Plug>VimLint
-
- " Zsh: check
- autocmd FileType zsh nmap <buffer> <LocalLeader>c <Plug>ZshCheck
-
- augroup END
-endif
-
-" Add packaged matchit.vim, if supported
-if has('packages')
- packadd! matchit
-endif
+ " Add packaged matchit.vim, if supported
+ if has('packages')
+ packadd! matchit
+ endif
-" Disable core plugins I don't use
-if 1
+ " Skip loading some plugins:
" I manage plugins myself with Git and a Makefile
let g:loaded_getscriptPlugin = 1
let g:loaded_vimballPlugin = 1
@@ -335,6 +297,7 @@ if 1
let g:loaded_rrhelper = 1
" I don't need extra spelling files
let g:loaded_spellfile_plugin = 1
+
endif
" Source any .vim files from ~/.vim/config