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. --- vim/filemap.vim | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 vim/filemap.vim (limited to 'vim/filemap.vim') 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 -- cgit v1.2.3