From f36ef6745c3c96914eb7be228125c1d53bf70287 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 10 Jul 2018 01:55:15 +1200 Subject: Overhaul after/ftplugin Use .= operator to append to b:undo_ftplugin, as we're requiring Vim 7.0 or later everywhere here anyway. Also remove &compatible where we don't need line breaks. --- vim/after/ftplugin/awk.vim | 6 ++---- vim/after/ftplugin/c.vim | 6 ++---- vim/after/ftplugin/cpp.vim | 6 ++---- vim/after/ftplugin/diff.vim | 5 ++--- vim/after/ftplugin/gitcommit.vim | 6 ++---- vim/after/ftplugin/help.vim | 5 ++--- vim/after/ftplugin/html.vim | 15 +++++---------- vim/after/ftplugin/mail.vim | 5 ++--- vim/after/ftplugin/make.vim | 5 ++--- vim/after/ftplugin/markdown.vim | 5 ++--- vim/after/ftplugin/perl.vim | 18 ++++++------------ vim/after/ftplugin/php.vim | 15 +++++---------- vim/after/ftplugin/sed.vim | 6 ++---- vim/after/ftplugin/sh.vim | 19 ++++++------------- vim/after/ftplugin/text.vim | 5 ++--- vim/after/ftplugin/vim.vim | 11 ++++------- vim/after/ftplugin/zsh.vim | 8 +++----- 17 files changed, 51 insertions(+), 95 deletions(-) (limited to 'vim') diff --git a/vim/after/ftplugin/awk.vim b/vim/after/ftplugin/awk.vim index 42b3e1db..6a8ac1ac 100644 --- a/vim/after/ftplugin/awk.vim +++ b/vim/after/ftplugin/awk.vim @@ -1,11 +1,9 @@ " Extra configuration for AWK scripts -if &filetype != 'awk' || &compatible || v:version < 700 +if &filetype !=# 'awk' || v:version < 700 finish endif " Set comment formats setlocal comments=:# setlocal formatoptions+=or -let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments<' - \ . '|setlocal formatoptions<' +let b:undo_ftplugin .= '|setlocal comments< formatoptions' diff --git a/vim/after/ftplugin/c.vim b/vim/after/ftplugin/c.vim index ff74d386..e101b20c 100644 --- a/vim/after/ftplugin/c.vim +++ b/vim/after/ftplugin/c.vim @@ -1,11 +1,9 @@ " Extra configuration for C files -if &filetype != 'c' || &compatible || v:version < 700 +if &filetype !=# 'c' || v:version < 700 finish endif " Set comment formats setlocal include=^\\s*#\\s*include setlocal path+=/usr/include -let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal include<' - \ . '|setlocal path<' +let b:undo_ftplugin .= '|setlocal include< path<' diff --git a/vim/after/ftplugin/cpp.vim b/vim/after/ftplugin/cpp.vim index 9a58cfa5..a826bf43 100644 --- a/vim/after/ftplugin/cpp.vim +++ b/vim/after/ftplugin/cpp.vim @@ -1,11 +1,9 @@ " Extra configuration for C++ files -if &filetype != 'cpp' || &compatible || v:version < 700 +if &filetype !=# 'cpp' || v:version < 700 finish endif " Set comment formats setlocal include=^\\s*#\\s*include setlocal path+=/usr/include -let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal include<' - \ . '|setlocal path<' +let b:undo_ftplugin .= '|setlocal include< path<' diff --git a/vim/after/ftplugin/diff.vim b/vim/after/ftplugin/diff.vim index 5b0e7b31..1e2bb2f8 100644 --- a/vim/after/ftplugin/diff.vim +++ b/vim/after/ftplugin/diff.vim @@ -1,5 +1,5 @@ " Extra configuration for diffs -if &filetype != 'diff' || &compatible || v:version < 700 +if &filetype !=# 'diff' || v:version < 700 || &compatible finish endif @@ -12,7 +12,6 @@ endif nmap p (DiffPrune) xmap p (DiffPrune) nmap pp (DiffPrune)_ -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap p' +let b:undo_ftplugin .= '|nunmap p' \ . '|xunmap p' \ . '|nunmap pp' diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index e55ebff7..8e365d98 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -1,11 +1,9 @@ " Extra configuration for Git commit messages -if &filetype != 'gitcommit' || &compatible || v:version < 700 +if &filetype !=# 'gitcommit' || v:version < 700 finish endif " Make angle brackets behave like mail quotes setlocal comments+=n:> setlocal formatoptions+=coqr -let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments<' - \ . '|setlocal formatoptions<' +let b:undo_ftplugin .= '|setlocal comments< formatoptions<' diff --git a/vim/after/ftplugin/help.vim b/vim/after/ftplugin/help.vim index 3d9ad072..eb5cea64 100644 --- a/vim/after/ftplugin/help.vim +++ b/vim/after/ftplugin/help.vim @@ -1,5 +1,5 @@ " Extra configuration for Vim help files -if &filetype != 'help' || &compatible || v:version < 700 +if &filetype !=# 'help' || v:version < 700 finish endif @@ -7,6 +7,5 @@ endif " reading it; don't conceal characters if &modifiable && !&readonly setlocal conceallevel=0 - let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal conceallevel' + let b:undo_ftplugin .= '|setlocal conceallevel<' endif diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim index d0625fb7..2faea4f5 100644 --- a/vim/after/ftplugin/html.vim +++ b/vim/after/ftplugin/html.vim @@ -1,16 +1,13 @@ " Extra configuration for HTML files -if &filetype != 'html' || &compatible || v:version < 700 +if &filetype !=# 'html' || v:version < 700 || &compatible finish endif " Use tidy(1) for checking and program formatting compiler tidy setlocal equalprg=tidy\ -quiet -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:current_compiler' - \ . '|setlocal equalprg<' - \ . '|setlocal errorformat<' - \ . '|setlocal makeprg<' +let b:undo_ftplugin .= '|unlet b:current_compiler' + \ . '|setlocal equalprg< errorformat< makeprg<' " Set up hooks for timestamp updating augroup html_timestamp @@ -19,8 +16,7 @@ augroup html_timestamp \| call html#TimestampUpdate() \|endif augroup END -let b:undo_ftplugin = b:undo_ftplugin - \ . '|autocmd! html_timestamp BufWritePre ' +let b:undo_ftplugin .= '|autocmd! html_timestamp BufWritePre ' " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_html_maps') @@ -30,5 +26,4 @@ endif " Set mappings nnoremap r \ :call html#UrlLink() -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap r' +let b:undo_ftplugin .= '|nunmap r' diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 200358d8..3ecc0310 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -1,9 +1,8 @@ " Extra configuration for mail messages -if &filetype != 'mail' || &compatible || v:version < 700 +if &filetype !=# 'mail' || v:version < 700 finish endif " Add a space to the end of wrapped lines for format-flowed mail setlocal formatoptions+=w -let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal formatoptions<' +let b:undo_ftplugin .= '|setlocal formatoptions<' diff --git a/vim/after/ftplugin/make.vim b/vim/after/ftplugin/make.vim index b946d547..f4b58f5b 100644 --- a/vim/after/ftplugin/make.vim +++ b/vim/after/ftplugin/make.vim @@ -1,5 +1,5 @@ " Extra configuration for Makefiles -if &filetype != 'make' || &compatible || v:version < 700 +if &filetype !=# 'make' || v:version < 700 finish endif @@ -11,6 +11,5 @@ endif " Set mappings if exists('b:undo_ftplugin') nmap m MakeTarget - let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap m' + let b:undo_ftplugin .= '|nunmap m' endif diff --git a/vim/after/ftplugin/markdown.vim b/vim/after/ftplugin/markdown.vim index 3c97dd97..d2cf8918 100644 --- a/vim/after/ftplugin/markdown.vim +++ b/vim/after/ftplugin/markdown.vim @@ -1,11 +1,10 @@ " Extra configuration for Markdown documents -if &filetype != 'markdown' || &compatible || v:version < 700 +if &filetype !=# 'markdown' || v:version < 700 finish endif " Spellcheck documents we're actually editing (not just viewing) if &modifiable && !&readonly setlocal spell - let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal spell<' + let b:undo_ftplugin .= '|setlocal spell<' endif diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim index dd5285e3..065a9512 100644 --- a/vim/after/ftplugin/perl.vim +++ b/vim/after/ftplugin/perl.vim @@ -1,21 +1,17 @@ " Extra configuration for Perl filetypes -if &filetype != 'perl' || &compatible || v:version < 700 +if &filetype !=# 'perl' || v:version < 700 || &compatible finish endif " Use Perl itself for checking and Perl::Tidy for tidying compiler perl setlocal equalprg=perltidy -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:current_compiler' - \ . '|setlocal equalprg<' - \ . '|setlocal errorformat<' - \ . '|setlocal makeprg<' +let b:undo_ftplugin .= '|unlet b:current_compiler' + \ . '|setlocal equalprg< errorformat< makeprg<' " Add angle brackets to pairs of matched characters for q<...> setlocal matchpairs+=<:> -let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal matchpairs<' +let b:undo_ftplugin .= '|setlocal matchpairs<' " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_perl_maps') @@ -27,8 +23,7 @@ nnoremap c \ :compiler perl nnoremap l \ :compiler perlcritic -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap c' +let b:undo_ftplugin .= '|nunmap c' \ . '|nunmap l' " Bump version numbers @@ -36,6 +31,5 @@ nmap v \ PerlVersionBumpMinor nmap V \ PerlVersionBumpMajor -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap v' +let b:undo_ftplugin .= '|nunmap v' \ . '|nunmap V' diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim index 765c1fb9..c98c1264 100644 --- a/vim/after/ftplugin/php.vim +++ b/vim/after/ftplugin/php.vim @@ -1,21 +1,17 @@ " Extra configuration for PHP scripts -if &filetype != 'php' || &compatible || v:version < 700 +if &filetype !=# 'php' || v:version < 700 || &compatible finish endif " Use PHP itself for syntax checking compiler php -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:current_compiler' - \ . '|setlocal errorformat<' - \ . '|setlocal makeprg<' +let b:undo_ftplugin .= '|unlet b:current_compiler' + \ . '|setlocal errorformat< makeprg<' " Set comment formats setlocal comments=s1:/*,m:*,ex:*/,://,:# setlocal formatoptions+=or -let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments<' - \ . '|setlocal formatoptions<' +let b:undo_ftplugin .= '|setlocal comments< formatoptions<' " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_php_maps') @@ -23,8 +19,7 @@ if exists('g:no_plugin_maps') || exists('g:no_php_maps') endif " Get rid of the core ftplugin's square-bracket maps on unload -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap [[' +let b:undo_ftplugin .= '|nunmap [[' \ . '|ounmap [[' \ . '|nunmap ]]' \ . '|ounmap ]]' diff --git a/vim/after/ftplugin/sed.vim b/vim/after/ftplugin/sed.vim index f4045d93..56447a34 100644 --- a/vim/after/ftplugin/sed.vim +++ b/vim/after/ftplugin/sed.vim @@ -1,11 +1,9 @@ " Extra configuration for sed scripts -if &filetype != 'sed' || &compatible || v:version < 700 +if &filetype !=# 'sed' || v:version < 700 finish endif " Set comment formats setlocal comments=:# setlocal formatoptions+=or -let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments<' - \ . '|setlocal formatoptions<' +let b:undo_ftplugin .= '|setlocal comments< formatoptions<' diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim index 5cafdd70..41b1796f 100644 --- a/vim/after/ftplugin/sh.vim +++ b/vim/after/ftplugin/sh.vim @@ -1,20 +1,17 @@ " Extra configuration for shell script -if &filetype != 'sh' || &compatible || v:version < 700 +if &filetype !=# 'sh' || v:version < 700 || &compatible finish endif " Set comment formats setlocal comments=:# setlocal formatoptions+=or -let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments<' - \ . '|setlocal formatoptions<' +let b:undo_ftplugin .= '|setlocal comments< formatoptions<' " If subtype is Bash, set 'keywordprg' to han(1df) if exists('b:is_bash') setlocal keywordprg=han - let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal keywordprg<' + let b:undo_ftplugin .= '|setlocal keywordprg<' endif " Choose check compiler based on file subtype @@ -26,11 +23,8 @@ else let b:sh_check_compiler = 'sh' endif execute 'compiler '.b:sh_check_compiler -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:current_compiler' - \ . '|unlet b:sh_check_compiler' - \ . '|setlocal errorformat<' - \ . '|setlocal makeprg<' +let b:undo_ftplugin .= '|unlet b:current_compiler b:sh_check_compiler' + \ . '|setlocal errorformat< makeprg<' " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_sh_maps') @@ -42,6 +36,5 @@ nnoremap c \ ':compiler '.b:sh_check_compiler.'' nnoremap l \ :compiler shellcheck -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap c' +let b:undo_ftplugin .= '|nunmap c' \ . '|nunmap l' diff --git a/vim/after/ftplugin/text.vim b/vim/after/ftplugin/text.vim index 0ca72122..67948706 100644 --- a/vim/after/ftplugin/text.vim +++ b/vim/after/ftplugin/text.vim @@ -1,11 +1,10 @@ " Extra configuration for text files -if &filetype != 'text' || &compatible || v:version < 700 +if &filetype !=# 'text' || v:version < 700 finish endif " Spellcheck documents we're actually editing (not just viewing) if &modifiable && !&readonly setlocal spell - let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal spell<' + let b:undo_ftplugin .= '|setlocal spell<' endif diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim index 2d11b2d6..2b8ddbb9 100644 --- a/vim/after/ftplugin/vim.vim +++ b/vim/after/ftplugin/vim.vim @@ -1,14 +1,12 @@ " Extra configuration for Vim scripts -if &filetype != 'vim' || &compatible || v:version < 700 +if &filetype !=# 'vim' || v:version < 700 || &compatible finish endif " Use Vint as a syntax checker compiler vint -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:current_compiler' - \ . '|setlocal errorformat<' - \ . '|setlocal makeprg<' +let b:undo_ftplugin .= '|unlet b:current_compiler' + \ . '|setlocal errorformat< makeprg' " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_vim_maps') @@ -16,8 +14,7 @@ if exists('g:no_plugin_maps') || exists('g:no_vim_maps') endif " Get rid of the core ftplugin's square-bracket maps on unload -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap [[' +let b:undo_ftplugin .= '|nunmap [[' \ . '|vunmap [[' \ . '|nunmap ]]' \ . '|vunmap ]]' diff --git a/vim/after/ftplugin/zsh.vim b/vim/after/ftplugin/zsh.vim index 8a27846b..49736401 100644 --- a/vim/after/ftplugin/zsh.vim +++ b/vim/after/ftplugin/zsh.vim @@ -1,11 +1,9 @@ " Extra configuration for Z shell scripts -if &filetype != 'zsh' || &compatible || v:version < 700 +if &filetype !=# 'zsh' || v:version < 700 || &compatible finish endif " Use Z shell itself as a syntax checker compiler zsh -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:current_compiler' - \ . '|setlocal errorformat<' - \ . '|setlocal makeprg<' +let b:undo_ftplugin .= '|unlet b:current_compiler' + \ . '|setlocal errorformat< makeprg<' -- cgit v1.2.3