From d115ba06a04b0772246da35af8e9dad87933a0d1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 30 Jun 2018 00:51:23 +1200 Subject: Review vim/ftplugin and vim/indent files --- vim/after/ftplugin/php.vim | 12 ++++++++++++ vim/after/indent/vim.vim | 12 ++++++++---- vim/ftplugin/markdown.vim | 30 +----------------------------- vim/ftplugin/php.vim | 23 +---------------------- vim/indent/password.vim | 2 +- vim/indent/php.vim | 6 +++--- 6 files changed, 26 insertions(+), 59 deletions(-) diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim index 4521ba7d..f9ff008f 100644 --- a/vim/after/ftplugin/php.vim +++ b/vim/after/ftplugin/php.vim @@ -16,6 +16,18 @@ let b:undo_ftplugin = b:undo_ftplugin \ . '|setlocal comments<' \ . '|setlocal formatoptions<' +" Define keywords for matchit.vim +if exists('g:loaded_matchit') + let b:match_words = '' + \ . ',\:\' + \ . ',\:\' + \ . ',\:\' + \ . ',\:\:\:\' + \ . ',\:\' + \ . ',\:\' + let b:undo_ftplugin = 'unlet b:match_words' +endif + " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_php_maps') finish diff --git a/vim/after/indent/vim.vim b/vim/after/indent/vim.vim index bfd92aeb..e46aae54 100644 --- a/vim/after/indent/vim.vim +++ b/vim/after/indent/vim.vim @@ -1,7 +1,11 @@ " Observe VimL conventions for two-space indents setlocal shiftwidth=2 -setlocal softtabstop=2 -if exists('b:undo_indent') - let s:ui = '|setlocal shiftwidth< softtabstop<' - let b:undo_indent = b:undo_indent . s:ui +let b:undo_indent = b:undo_indent . '|setlocal shiftwidth<' + +" If we need to set 'softtabstop' too, do it +if &softtabstop == -1 + setlocal softtabstop=2 + if exists('b:undo_indent') + let b:undo_indent = b:undo_indent . '|setlocal softtabstop<' + endif endif diff --git a/vim/ftplugin/markdown.vim b/vim/ftplugin/markdown.vim index e1787df5..1e40c0ef 100644 --- a/vim/ftplugin/markdown.vim +++ b/vim/ftplugin/markdown.vim @@ -1,33 +1,5 @@ -" -" Replace Vim's stock Markdown filetype plugin, reimplementing only the part I -" actually need: the options settings. I don't use the folding, anyway. -" -" This is mostly because the stock file pulls in HTML's filetype plugins too, -" without providing a variable check to stop it. That causes absurd problems -" with defining HTML checkers/linters in the rest of my files. -" +" Block system ftplugin from loading to avoid HTML ftplugin load if exists('b:did_ftplugin') || &compatible finish endif let b:did_ftplugin = 1 - -" Set comment/quote patterns -setlocal comments=fb:*,fb:-,fb:+,n:> -setlocal commentstring=>\ %s - -" Set format options -setlocal formatoptions+=tcqln -setlocal formatoptions-=ro - -" Set list format patterns -if exists('+formatlistpat') - let &l:formatlistpat = '^\s*\d\+\.\s\+' - \ .'\|^[-*+]\s\+' - \ .'\|^\[^\ze[^\]]\+\]:' -endif - -" Define how to undo this plugin's settings -let b:undo_ftplugin = 'setlocal comments<' - \ . '|setlocal commentstring<' - \ . '|setlocal formatoptions<' - \ . '|setlocal formatlistpat<' diff --git a/vim/ftplugin/php.vim b/vim/ftplugin/php.vim index 35292e15..1e40c0ef 100644 --- a/vim/ftplugin/php.vim +++ b/vim/ftplugin/php.vim @@ -1,26 +1,5 @@ -" -" Replace Vim's stock PHP filetype plugin, reimplementing only the part I -" actually need: the matchit.vim keyword pairs. -" -" This is mostly because the stock file pulls in HTML's filetype plugins too, -" without providing a variable check to stop it. That causes absurd problems -" with defining HTML checkers/linters in the rest of my files. -" +" Block system ftplugin from loading to avoid HTML ftplugin load if exists('b:did_ftplugin') || &compatible finish endif let b:did_ftplugin = 1 - -" Define keywords for matchit.vim -if exists('g:loaded_matchit') - let b:match_words = '' - \ . ',\:\' - \ . ',\:\' - \ . ',\:\' - \ . ',\:\:\:\' - \ . ',\:\' - \ . ',\:\' -endif - -" Define how to undo this plugin's settings -let b:undo_ftplugin = 'unlet b:match_words' diff --git a/vim/indent/password.vim b/vim/indent/password.vim index e633fe05..e37d0387 100644 --- a/vim/indent/password.vim +++ b/vim/indent/password.vim @@ -4,7 +4,7 @@ if exists('b:did_indent') endif let b:did_indent = 1 -" Manual indenting and literal tabs +" Manual indenting and literal tabs for passwords setlocal noautoindent setlocal noexpandtab setlocal softtabstop=0 diff --git a/vim/indent/php.vim b/vim/indent/php.vim index 6a61f105..7747d77e 100644 --- a/vim/indent/php.vim +++ b/vim/indent/php.vim @@ -1,10 +1,10 @@ -" Replace Vim's stock PHP indent rules. They're very complicated and don't -" work in a predictable way. +" Only do this when not done yet for this buffer if exists('b:did_indent') finish endif let b:did_indent = 1 -" Easier just to use 'autoindent'; not perfect, but predictable. +" Replace Vim's stock PHP indent rules. They're very complicated and don't +" work in a predictable way. Just use 'autoindent'. setlocal autoindent let b:undo_indent = 'setlocal autoindent<' -- cgit v1.2.3