From 10c601851625784c7058f52c8d88bdb2e99b5620 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 23:13:02 +1200 Subject: Overhaul base after-ftplugins Mostly to simplify them--remove a lot of the load-guard cruft. --- vim/after/ftplugin/awk.vim | 16 ++++------------ vim/after/ftplugin/c.vim | 16 ++++------------ vim/after/ftplugin/cpp.vim | 16 ++++------------ vim/after/ftplugin/diff.vim | 13 ++----------- vim/after/ftplugin/gitcommit.vim | 22 +++++++++------------- vim/after/ftplugin/help.vim | 13 ++----------- vim/after/ftplugin/html.vim | 27 +++++++-------------------- vim/after/ftplugin/mail.vim | 13 ++----------- vim/after/ftplugin/make.vim | 21 +++++++-------------- vim/after/ftplugin/markdown.vim | 13 ++----------- vim/after/ftplugin/perl.vim | 13 ++----------- vim/after/ftplugin/php.vim | 16 ++++------------ vim/after/ftplugin/sed.vim | 16 ++++------------ vim/after/ftplugin/sh.vim | 18 ++++++------------ vim/after/ftplugin/text.vim | 13 ++----------- vim/after/ftplugin/vim.vim | 13 ++----------- vim/after/ftplugin/zsh.vim | 13 ++----------- 17 files changed, 65 insertions(+), 207 deletions(-) (limited to 'vim/after/ftplugin') diff --git a/vim/after/ftplugin/awk.vim b/vim/after/ftplugin/awk.vim index fae66c3c..42b3e1db 100644 --- a/vim/after/ftplugin/awk.vim +++ b/vim/after/ftplugin/awk.vim @@ -1,19 +1,11 @@ -" Extra configuration for 'awk' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for AWK scripts +if &filetype != 'awk' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'awk' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Set comment formats setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments< formatoptions<' + \ . '|setlocal comments<' + \ . '|setlocal formatoptions<' diff --git a/vim/after/ftplugin/c.vim b/vim/after/ftplugin/c.vim index d98aa130..ff74d386 100644 --- a/vim/after/ftplugin/c.vim +++ b/vim/after/ftplugin/c.vim @@ -1,19 +1,11 @@ -" Extra configuration for 'c' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for C files +if &filetype != 'c' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'c' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Set comment formats setlocal include=^\\s*#\\s*include setlocal path+=/usr/include let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal include< path<' + \ . '|setlocal include<' + \ . '|setlocal path<' diff --git a/vim/after/ftplugin/cpp.vim b/vim/after/ftplugin/cpp.vim index acecf3e5..9a58cfa5 100644 --- a/vim/after/ftplugin/cpp.vim +++ b/vim/after/ftplugin/cpp.vim @@ -1,19 +1,11 @@ -" Extra configuration for 'cpp' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for C++ files +if &filetype != 'cpp' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'cpp' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Set comment formats setlocal include=^\\s*#\\s*include setlocal path+=/usr/include let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal include< path<' + \ . '|setlocal include<' + \ . '|setlocal path<' diff --git a/vim/after/ftplugin/diff.vim b/vim/after/ftplugin/diff.vim index ecb651ff..5b0e7b31 100644 --- a/vim/after/ftplugin/diff.vim +++ b/vim/after/ftplugin/diff.vim @@ -1,16 +1,7 @@ -" Extra configuration for 'diff' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for diffs +if &filetype != 'diff' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'diff' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_diff_maps') diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index d903e84e..035b835c 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -1,19 +1,15 @@ -" Extra configuration for 'gitcommit' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for Git commit messages +if &filetype != 'gitcommit' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'gitcommit' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Make angle brackets behave like mail quotes setlocal comments+=n:> setlocal formatoptions+=coqr -let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments< formatoptions<' + +" Add to undo script +if exists('b:undo_ftplugin') + let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal comments<' + \ . '|setlocal formatoptions<' +endif diff --git a/vim/after/ftplugin/help.vim b/vim/after/ftplugin/help.vim index ad6b572c..3d9ad072 100644 --- a/vim/after/ftplugin/help.vim +++ b/vim/after/ftplugin/help.vim @@ -1,16 +1,7 @@ -" Extra configuration for 'help' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for Vim help files +if &filetype != 'help' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'help' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " If the buffer is modifiable and writable, we're writing documentation, not " reading it; don't conceal characters diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim index 8a1c22d4..545076b1 100644 --- a/vim/after/ftplugin/html.vim +++ b/vim/after/ftplugin/html.vim @@ -1,28 +1,15 @@ -" Extra configuration for 'html' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for HTML files +if &filetype != 'html' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'html' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Set up hooks for timestamp updating -augroup html_timestamp - autocmd! - autocmd BufWritePre *.html - \ if exists('b:html_timestamp_check') - \| call html#TimestampUpdate() - \|endif -augroup END +autocmd html_timestamp BufWritePre + \ if exists('b:html_timestamp_check') + \| call html#TimestampUpdate() + \|endif let b:undo_ftplugin = b:undo_ftplugin - \ . '|augroup html_timestamp|autocmd!|augroup END' - \ . '|augroup! html_timestamp' + \ . '|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') diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 68e9e17a..200358d8 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -1,16 +1,7 @@ -" Extra configuration for 'mail' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for mail messages +if &filetype != 'mail' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'mail' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Add a space to the end of wrapped lines for format-flowed mail setlocal formatoptions+=w diff --git a/vim/after/ftplugin/make.vim b/vim/after/ftplugin/make.vim index 30db753f..b946d547 100644 --- a/vim/after/ftplugin/make.vim +++ b/vim/after/ftplugin/make.vim @@ -1,16 +1,7 @@ -" Extra configuration for 'make' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for Makefiles +if &filetype != 'make' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'make' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_make_maps') @@ -18,6 +9,8 @@ if exists('g:no_plugin_maps') || exists('g:no_make_maps') endif " Set mappings -nmap m MakeTarget -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap m' +if exists('b:undo_ftplugin') + nmap m MakeTarget + let b:undo_ftplugin = b:undo_ftplugin + \ . '|nunmap m' +endif diff --git a/vim/after/ftplugin/markdown.vim b/vim/after/ftplugin/markdown.vim index 69b794dd..3c97dd97 100644 --- a/vim/after/ftplugin/markdown.vim +++ b/vim/after/ftplugin/markdown.vim @@ -1,16 +1,7 @@ -" Extra configuration for 'markdown' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for Markdown documents +if &filetype != 'markdown' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'markdown' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Spellcheck documents we're actually editing (not just viewing) if &modifiable && !&readonly diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim index 1a7df559..8887b56a 100644 --- a/vim/after/ftplugin/perl.vim +++ b/vim/after/ftplugin/perl.vim @@ -1,16 +1,7 @@ -" Extra configuration for 'perl' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for Perl filetypes +if &filetype != 'perl' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'perl' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_perl_maps') diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim index 70e92dfd..35849ac5 100644 --- a/vim/after/ftplugin/php.vim +++ b/vim/after/ftplugin/php.vim @@ -1,22 +1,14 @@ -" Extra configuration for 'php' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for PHP scripts +if &filetype != 'php' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'php' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Set comment formats setlocal comments=s1:/*,m:*,ex:*/,://,:# setlocal formatoptions+=or let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments< formatoptions<' + \ . '|setlocal comments<' + \ . '|setlocal formatoptions<' " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_php_maps') diff --git a/vim/after/ftplugin/sed.vim b/vim/after/ftplugin/sed.vim index e16ec53d..f4045d93 100644 --- a/vim/after/ftplugin/sed.vim +++ b/vim/after/ftplugin/sed.vim @@ -1,19 +1,11 @@ -" Extra configuration for 'sed' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for sed scripts +if &filetype != 'sed' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'sed' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Set comment formats setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments< formatoptions<' + \ . '|setlocal comments<' + \ . '|setlocal formatoptions<' diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim index 05c3e293..086e23d5 100644 --- a/vim/after/ftplugin/sh.vim +++ b/vim/after/ftplugin/sh.vim @@ -1,22 +1,14 @@ -" Extra configuration for 'sh' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for shell script +if &filetype != 'sh' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'sh' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Set comment formats setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments< formatoptions<' + \ . '|setlocal comments<' + \ . '|setlocal formatoptions<' " If subtype is Bash, set 'keywordprg' to han(1df) if exists('b:is_bash') @@ -38,6 +30,8 @@ elseif exists('b:is_kornshell') else let b:sh_check_compiler = 'sh' endif +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:sh_check_compiler' " Set mappings nnoremap c diff --git a/vim/after/ftplugin/text.vim b/vim/after/ftplugin/text.vim index 83a9dcd8..0ca72122 100644 --- a/vim/after/ftplugin/text.vim +++ b/vim/after/ftplugin/text.vim @@ -1,16 +1,7 @@ -" Extra configuration for 'text' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for text files +if &filetype != 'text' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'text' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Spellcheck documents we're actually editing (not just viewing) if &modifiable && !&readonly diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim index 9710b2d8..e01e2050 100644 --- a/vim/after/ftplugin/vim.vim +++ b/vim/after/ftplugin/vim.vim @@ -1,16 +1,7 @@ -" Extra configuration for 'vim' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for Vim scripts +if &filetype != 'vim' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'vim' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_vim_maps') diff --git a/vim/after/ftplugin/zsh.vim b/vim/after/ftplugin/zsh.vim index eb5fc035..79f3c638 100644 --- a/vim/after/ftplugin/zsh.vim +++ b/vim/after/ftplugin/zsh.vim @@ -1,16 +1,7 @@ -" Extra configuration for 'zsh' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for Z shell scripts +if &filetype != 'zsh' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'zsh' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_zsh_maps') -- cgit v1.2.3