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/vimrc | 60 +++++++++++------------------------------------------------- 1 file changed, 11 insertions(+), 49 deletions(-) (limited to 'vim/vimrc') 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