From 9be8677d0a3f29e054541b45670c1f7f090c5f6d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 26 Jun 2018 10:34:26 +1200 Subject: Remap normal J only if loading plugins This will also deftly dodge vim-tiny. --- vim/vimrc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 2e90ecbe..4873b9cd 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -200,9 +200,10 @@ nnoremap ]t :tabnext nmap [ PutBlankLinesAbove nmap ] PutBlankLinesBelow -" Remap normal J to stay in place while joining lines; fall back to default -nnoremap FixedJoin J -nmap J FixedJoin +" Remap normal J to stay in place while joining lines +if &loadplugins + nmap J FixedJoin +endif " Remap normal Y to yank to end of line (consistent with C, D) nnoremap Y y$ -- cgit v1.2.3 From c8816903f0dbae151385f7198610f24ad945c01d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 26 Jun 2018 10:51:06 +1200 Subject: Refactor filetype-specific .vimrc material Put filetype bindings into a separate file filemap.vim at the same level as filetype.vim, to be loaded directly after the "filetype" command. This removes per-filetype logic one step from ~/.vimrc, which seems appropriate, and also allows me to use long line breaks in the new file. --- Makefile | 3 +-- vim/filemap.vim | 51 +++++++++++++++++++++++++++++++++++++++++++++++ vim/filetype.vim | 24 +++++++++++------------ vim/vimrc | 60 +++++++++++--------------------------------------------- 4 files changed, 75 insertions(+), 63 deletions(-) create mode 100644 vim/filemap.vim diff --git a/Makefile b/Makefile index 74524338..d031574c 100644 --- a/Makefile +++ b/Makefile @@ -548,8 +548,7 @@ install-vim-config: cp -p -- vim/vimrc $(VIMRC) install-vim-filetype: - cp -p -- vim/filetype.vim $(VIMDIR) - cp -p -- vim/scripts.vim $(VIMDIR) + cp -p -- vim/filemap.vim vim/filetype.vim vim/scripts.vim $(VIMDIR) install-vim-ftplugin: mkdir -p -- $(VIMDIR)/ftplugin 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 p DiffPrune + \|xmap p DiffPrune + + " HTML: lint, URL-to-link, tidy + autocmd FileType html + \ nmap l HtmlLint + \|nmap r HtmlUrlLink + \|nmap t HtmlTidy + + " Perl: check, lint, and tidy + autocmd FileType perl + \ nmap c PerlCheck + \|nmap l PerlLint + \|nmap t PerlTidy + + " PHP: check + autocmd FileType php + \ nmap c PhpCheck + + " Shell: check and lint + autocmd FileType sh + \ nmap c ShCheck + \|nmap l ShLint + + " VimL: lint + autocmd FileType vim + \ nmap l VimLint + + " Zsh: check + autocmd FileType zsh + \ nmap c 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 4873b9cd..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 @@ -271,56 +273,15 @@ nmap x StripTrailingWhitespace " \z sets NZ English spelling (compare \u) nnoremap \z :setlocal spelllang=en_nz spelllang? -" 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 p DiffPrune - autocmd FileType diff xmap p DiffPrune - - " HTML: lint, URL-to-link, tidy - autocmd FileType html nmap l HtmlLint - autocmd FileType html nmap r HtmlUrlLink - autocmd FileType html nmap t HtmlTidy - - " Perl: check, lint, and tidy - autocmd FileType perl nmap c PerlCheck - autocmd FileType perl nmap l PerlLint - autocmd FileType perl nmap t PerlTidy - - " PHP: check - autocmd FileType php nmap c PhpCheck - - " Shell: check and lint - autocmd FileType sh nmap c ShCheck - autocmd FileType sh nmap l ShLint - - " VimL: lint - autocmd FileType vim nmap l VimLint - - " Zsh: check - autocmd FileType zsh nmap c ZshCheck - - augroup END -endif +" Settings for plugins +if &loadplugins -" 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 @@ -336,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 -- cgit v1.2.3 From 757ee5eb863378d7a19c360d51d96bf9544786a7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 26 Jun 2018 11:13:18 +1200 Subject: Clear away VimL mapping rubbish --- vim/after/ftplugin/vim/clear_maps.vim | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 vim/after/ftplugin/vim/clear_maps.vim 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 [[' + \ . '|silent! vunmap [[' + \ . '|silent! nunmap ]]' + \ . '|silent! vunmap ]]' + \ . '|silent! nunmap []' + \ . '|silent! vunmap []' + \ . '|silent! nunmap ][' + \ . '|silent! vunmap ][' + \ . '|silent! nunmap ]"' + \ . '|silent! vunmap ]"' + \ . '|silent! nunmap ["' + \ . '|silent! vunmap ["' -- cgit v1.2.3 From 282309b558f64ce3ab7190bb6f4b3bfad44579b5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 26 Jun 2018 11:16:26 +1200 Subject: Update clear_local_maps.vim plugin --- vim/bundle/clear_local_maps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/clear_local_maps b/vim/bundle/clear_local_maps index b1038f42..61fb4c09 160000 --- a/vim/bundle/clear_local_maps +++ b/vim/bundle/clear_local_maps @@ -1 +1 @@ -Subproject commit b1038f42ef051f2829464b60d3a4aa13f3020d35 +Subproject commit 61fb4c0926d4f26014e1765bf6d22c1d968c6f8e -- cgit v1.2.3 From 71c0add471fdb6400ebc8b48686358dd6d118b05 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 26 Jun 2018 11:18:02 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 80c0ce82..d63c5dc3 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v1.5.0 -Mon Jun 25 21:27:11 UTC 2018 +tejr dotfiles v1.6.0 +Mon Jun 25 23:17:59 UTC 2018 -- cgit v1.2.3