From ad69b8aca286a9aa5f95f920199370e5512abcf7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jun 2018 23:24:06 +1200 Subject: Use ftplugins for filetype mappings instead --- vim/after/ftplugin/diff/maps.vim | 23 +++++++++++++++ vim/after/ftplugin/html/maps.vim | 25 ++++++++++++++++ vim/after/ftplugin/make/maps.vim | 21 +++++++++++++ vim/after/ftplugin/perl/maps.vim | 25 ++++++++++++++++ vim/after/ftplugin/php/maps.vim | 21 +++++++++++++ vim/after/ftplugin/sh/maps.vim | 23 +++++++++++++++ vim/after/ftplugin/vim/clear_maps.vim | 37 ----------------------- vim/after/ftplugin/vim/maps.vim | 37 +++++++++++++++++++++++ vim/after/ftplugin/zsh/maps.vim | 21 +++++++++++++ vim/bundle/clear_local_maps | 1 - vim/filemap.vim | 55 ----------------------------------- vim/vimrc | 1 - 12 files changed, 196 insertions(+), 94 deletions(-) create mode 100644 vim/after/ftplugin/diff/maps.vim create mode 100644 vim/after/ftplugin/html/maps.vim create mode 100644 vim/after/ftplugin/make/maps.vim create mode 100644 vim/after/ftplugin/perl/maps.vim create mode 100644 vim/after/ftplugin/php/maps.vim create mode 100644 vim/after/ftplugin/sh/maps.vim delete mode 100644 vim/after/ftplugin/vim/clear_maps.vim create mode 100644 vim/after/ftplugin/vim/maps.vim create mode 100644 vim/after/ftplugin/zsh/maps.vim delete mode 160000 vim/bundle/clear_local_maps delete mode 100644 vim/filemap.vim (limited to 'vim') diff --git a/vim/after/ftplugin/diff/maps.vim b/vim/after/ftplugin/diff/maps.vim new file mode 100644 index 00000000..f4ef8fd6 --- /dev/null +++ b/vim/after/ftplugin/diff/maps.vim @@ -0,0 +1,23 @@ +" diff/maps.vim: tejr's mappings for 'diff' filetypes + +" 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_diff_maps') + finish +endif + +" Flag as loaded +let b:did_ftplugin_diff_maps = 1 +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:did_ftplugin_diff_maps' + +" Set mappings +nmap p DiffPrune +xmap p DiffPrune +let b:undo_ftplugin = b:undo_ftplugin + \ . '|nunmap p' + \ . '|xunmap p' diff --git a/vim/after/ftplugin/html/maps.vim b/vim/after/ftplugin/html/maps.vim new file mode 100644 index 00000000..e355d0e6 --- /dev/null +++ b/vim/after/ftplugin/html/maps.vim @@ -0,0 +1,25 @@ +" html/maps.vim: tejr's mappings for 'html' filetypes + +" 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_html_maps') + finish +endif + +" Flag as loaded +let b:did_ftplugin_html_maps = 1 +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:did_ftplugin_html_maps' + +" Set mappings +nmap l HtmlLint +nmap r HtmlUrlLink +nmap t HtmlTidy +let b:undo_ftplugin = b:undo_ftplugin + \ . '|nunmap l' + \ . '|nunmap r' + \ . '|nunmap t' diff --git a/vim/after/ftplugin/make/maps.vim b/vim/after/ftplugin/make/maps.vim new file mode 100644 index 00000000..bfe82891 --- /dev/null +++ b/vim/after/ftplugin/make/maps.vim @@ -0,0 +1,21 @@ +" make/maps.vim: tejr's mappings for 'make' filetypes + +" 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_make_maps') + finish +endif + +" Flag as loaded +let b:did_ftplugin_make_maps = 1 +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:did_ftplugin_make_maps' + +" Set mappings +nmap m MakeTarget +let b:undo_ftplugin = b:undo_ftplugin + \ . '|nunmap m' diff --git a/vim/after/ftplugin/perl/maps.vim b/vim/after/ftplugin/perl/maps.vim new file mode 100644 index 00000000..fe5def10 --- /dev/null +++ b/vim/after/ftplugin/perl/maps.vim @@ -0,0 +1,25 @@ +" perl/maps.vim: tejr's mappings for 'perl' filetypes + +" 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_perl_maps') + finish +endif + +" Flag as loaded +let b:did_ftplugin_perl_maps = 1 +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:did_ftplugin_perl_maps' + +" Set mappings +nmap c PerlCheck +nmap l PerlLint +nmap t PerlTidy +let b:undo_ftplugin = b:undo_ftplugin + \ . '|nunmap c' + \ . '|nunmap l' + \ . '|nunmap t' diff --git a/vim/after/ftplugin/php/maps.vim b/vim/after/ftplugin/php/maps.vim new file mode 100644 index 00000000..32cc8388 --- /dev/null +++ b/vim/after/ftplugin/php/maps.vim @@ -0,0 +1,21 @@ +" php/maps.vim: tejr's mappings for 'php' filetypes + +" 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_php_maps') + finish +endif + +" Flag as loaded +let b:did_ftplugin_php_maps = 1 +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:did_ftplugin_php_maps' + +" Set mappings +nmap c PhpCheck +let b:undo_ftplugin = b:undo_ftplugin + \ . '|nunmap c' diff --git a/vim/after/ftplugin/sh/maps.vim b/vim/after/ftplugin/sh/maps.vim new file mode 100644 index 00000000..e93a84c4 --- /dev/null +++ b/vim/after/ftplugin/sh/maps.vim @@ -0,0 +1,23 @@ +" sh/maps.vim: tejr's mappings for 'sh' filetypes + +" 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_sh_maps') + finish +endif + +" Flag as loaded +let b:did_ftplugin_sh_maps = 1 +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:did_ftplugin_sh_maps' + +" Set mappings +nmap c ShCheck +nmap l ShLint +let b:undo_ftplugin = b:undo_ftplugin + \ . '|nunmap c' + \ . '|nunmap l' diff --git a/vim/after/ftplugin/vim/clear_maps.vim b/vim/after/ftplugin/vim/clear_maps.vim deleted file mode 100644 index a84ca4b9..00000000 --- a/vim/after/ftplugin/vim/clear_maps.vim +++ /dev/null @@ -1,37 +0,0 @@ -" 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 ["' diff --git a/vim/after/ftplugin/vim/maps.vim b/vim/after/ftplugin/vim/maps.vim new file mode 100644 index 00000000..7f2a07a0 --- /dev/null +++ b/vim/after/ftplugin/vim/maps.vim @@ -0,0 +1,37 @@ +" vim/maps.vim: tejr's mappings for 'vim' filetypes + +" 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_maps') + finish +endif + +" Flag as loaded +let b:did_ftplugin_vim_maps = 1 +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:did_ftplugin_vim_maps' + +" Set mappings +nmap l VimLint +let b:undo_ftplugin = b:undo_ftplugin + \ . '|nunmap l' + +" Add undo commands to fix clearing buffer-local vim maps that the core +" ftplugin leaves in place +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 ["' diff --git a/vim/after/ftplugin/zsh/maps.vim b/vim/after/ftplugin/zsh/maps.vim new file mode 100644 index 00000000..a670df46 --- /dev/null +++ b/vim/after/ftplugin/zsh/maps.vim @@ -0,0 +1,21 @@ +" zsh/maps.zsh: tejr's mappings for 'zsh' filetypes + +" 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_zsh_maps') + finish +endif + +" Flag as loaded +let b:did_ftplugin_zsh_maps = 1 +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:did_ftplugin_zsh_maps' + +" Set mappings +nmap c ZshCheck +let b:undo_ftplugin = b:undo_ftplugin + \ . '|nunmap c' diff --git a/vim/bundle/clear_local_maps b/vim/bundle/clear_local_maps deleted file mode 160000 index 61fb4c09..00000000 --- a/vim/bundle/clear_local_maps +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 61fb4c0926d4f26014e1765bf6d22c1d968c6f8e diff --git a/vim/filemap.vim b/vim/filemap.vim deleted file mode 100644 index d20a2037..00000000 --- a/vim/filemap.vim +++ /dev/null @@ -1,55 +0,0 @@ -" 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 - - " Makefile: make target - autocmd FileType make - \ nmap m MakeTarget - - " 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/vimrc b/vim/vimrc index a0722a7c..1067d09a 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -8,7 +8,6 @@ if has('autocmd') let g:maplocalleader = '_' filetype plugin indent on - runtime filemap.vim endif " Options dependent on the syntax feature -- cgit v1.2.3