From f547c632144a0f9149d52b9197a8c27c136d7a45 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 16:49:48 +1200 Subject: Correct a comment on shebang_update.vim --- vim/plugin/shebang_update.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/plugin/shebang_update.vim b/vim/plugin/shebang_update.vim index 1dbcaf67..60031e26 100644 --- a/vim/plugin/shebang_update.vim +++ b/vim/plugin/shebang_update.vim @@ -1,5 +1,5 @@ " -" shabeng_update.vim: If the first line of a file was changed, re-run +" shebang_update.vim: If the first line of a file was changed, re-run " " scripts.vim to do shebang detection to update the filetype. " " Author: Tom Ryder -- cgit v1.2.3 From 429baff887592f8f29aecec6ed8d6c57a3cf6600 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 17:23:15 +1200 Subject: Correct filetype reset; blank, not NONE --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index 982bd5ba..7a936ba0 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -273,7 +273,7 @@ nnoremap s :setlocal spell! spell? " \t shows current filetype nnoremap t :setlocal filetype? " \T clears filetype (follow with \R) -nnoremap T :setlocal filetype=NONE +nnoremap T :setlocal filetype= " \u sets US English spelling (compare \z) nnoremap u :setlocal spelllang=en_us " \v shows all global variables -- cgit v1.2.3 From eb3869b1e1f884da397fbe39716ed5448cf3f97e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 17:24:18 +1200 Subject: Use stridx() for shebang check --- vim/scripts.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/scripts.vim b/vim/scripts.vim index cbef0b4e..2dc602d7 100644 --- a/vim/scripts.vim +++ b/vim/scripts.vim @@ -6,7 +6,7 @@ let s:line = getline(1) " If it's not a shebang, we're done -if s:line !~# '\m^#!' +if stridx(s:line, '#!') != 0 finish endif -- cgit v1.2.3 From cbb65c137e969cae4d442411c6796a6027316a2e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 17:24:41 +1200 Subject: Move shebang updating into filetype.vim Much more logical location. --- vim/autoload/shebang.vim | 7 ------- vim/filetype.vim | 13 +++++++++++++ vim/plugin/shebang_update.vim | 20 -------------------- 3 files changed, 13 insertions(+), 27 deletions(-) delete mode 100644 vim/autoload/shebang.vim delete mode 100644 vim/plugin/shebang_update.vim diff --git a/vim/autoload/shebang.vim b/vim/autoload/shebang.vim deleted file mode 100644 index f39fcf48..00000000 --- a/vim/autoload/shebang.vim +++ /dev/null @@ -1,7 +0,0 @@ -" If the first line was changed in the last insert operation, re-run script -" detection -function! shebang#Update() abort - if line("'[") == 1 - runtime scripts.vim - endif -endfunction diff --git a/vim/filetype.vim b/vim/filetype.vim index ad2545a0..bda01984 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -42,6 +42,13 @@ function! s:StripRepeat() endfunction +" Check if the first line is a shebang +function! s:CheckShebang() + if line('''[') == 1 && stridx(getline(1), '#!') == 0 + doautocmd filetypedetect BufRead + endif +endfunction + " Use our own filetype detection rules augroup filetypedetect autocmd! @@ -508,4 +515,10 @@ augroup filetypedetect \| runtime scripts.vim \|endif + " If supported, on leaving insert mode, check whether the first line was " + " changed and is a shebang format, and if so, re-run filetype detection + if v:version > 700 + autocmd InsertLeave * call s:CheckShebang() + endif + augroup END diff --git a/vim/plugin/shebang_update.vim b/vim/plugin/shebang_update.vim deleted file mode 100644 index 60031e26..00000000 --- a/vim/plugin/shebang_update.vim +++ /dev/null @@ -1,20 +0,0 @@ -" -" shebang_update.vim: If the first line of a file was changed, re-run " -" scripts.vim to do shebang detection to update the filetype. -" -" Author: Tom Ryder -" License: Same as Vim itself -" -if exists('g:loaded_shebang_update') || &compatible - finish -endif -if v:version < 700 - finish -endif -let g:loaded_shebang_update = 1 - -" Call the update function whenever leaving insert mode -augroup shebang_update - autocmd! - autocmd InsertLeave * call shebang#Update() -augroup END -- cgit v1.2.3 From 882ea103b7a7be226ee58b5df0948dd73e192c6f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 21:02:57 +1200 Subject: Add patterns for Vim help file detection --- vim/after/ftplugin/diff.vim | 1 + vim/filetype.vim | 2 ++ 2 files changed, 3 insertions(+) diff --git a/vim/after/ftplugin/diff.vim b/vim/after/ftplugin/diff.vim index 6098ce48..a8f77125 100644 --- a/vim/after/ftplugin/diff.vim +++ b/vim/after/ftplugin/diff.vim @@ -19,6 +19,7 @@ endif " Set mappings nmap p DiffPrune +nmap pp (DiffPrune)l xmap p DiffPrune let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap p' diff --git a/vim/filetype.vim b/vim/filetype.vim index bda01984..440ee6e1 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -172,6 +172,8 @@ augroup filetypedetect " Vim help files autocmd BufNewFile,BufRead \ ~/.vim/doc/?*.txt + \,*/vim-*/doc/?*.txt + \,*/*.vim/doc/?*.txt \,$VIMRUNTIME/doc/?*.txt \ setfiletype help " HTML files -- cgit v1.2.3 From e3d1467a0c4bb10effd012e87f53a8c93a17ee60 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 21:04:06 +1200 Subject: Disable concealing when editing Vim help --- vim/after/ftplugin/help.vim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 vim/after/ftplugin/help.vim diff --git a/vim/after/ftplugin/help.vim b/vim/after/ftplugin/help.vim new file mode 100644 index 00000000..ad6b572c --- /dev/null +++ b/vim/after/ftplugin/help.vim @@ -0,0 +1,21 @@ +" Extra configuration for 'help' filetypes +if exists('b:did_ftplugin_after') || &compatible + 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 +if &modifiable && !&readonly + setlocal conceallevel=0 + let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal conceallevel' +endif -- cgit v1.2.3 From ed11c7e686c9c856da25d73d236d9c3798b94bc2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 21:05:11 +1200 Subject: Test 'modifiable' for spellchecking text/markdown --- vim/after/ftplugin/markdown.vim | 2 +- vim/after/ftplugin/text.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/after/ftplugin/markdown.vim b/vim/after/ftplugin/markdown.vim index 7ec37c64..69b794dd 100644 --- a/vim/after/ftplugin/markdown.vim +++ b/vim/after/ftplugin/markdown.vim @@ -13,7 +13,7 @@ let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_after' " Spellcheck documents we're actually editing (not just viewing) -if !&readonly +if &modifiable && !&readonly setlocal spell let b:undo_ftplugin = b:undo_ftplugin \ . '|setlocal spell<' diff --git a/vim/after/ftplugin/text.vim b/vim/after/ftplugin/text.vim index 06ca464a..83a9dcd8 100644 --- a/vim/after/ftplugin/text.vim +++ b/vim/after/ftplugin/text.vim @@ -13,7 +13,7 @@ let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_after' " Spellcheck documents we're actually editing (not just viewing) -if !&readonly +if &modifiable && !&readonly setlocal spell let b:undo_ftplugin = b:undo_ftplugin \ . '|setlocal spell<' -- cgit v1.2.3 From 3ab80b090d032b8b54fdab34a33c5915811d0292 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 21:08:48 +1200 Subject: Highlight overly long Git commit subjects as error --- vim/after/syntax/gitcommit.vim | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 vim/after/syntax/gitcommit.vim diff --git a/vim/after/syntax/gitcommit.vim b/vim/after/syntax/gitcommit.vim new file mode 100644 index 00000000..e47091f9 --- /dev/null +++ b/vim/after/syntax/gitcommit.vim @@ -0,0 +1,2 @@ +" If my commit subject is too long, highlight it as an error. +highlight link gitCommitOverflow Error -- cgit v1.2.3 From 20d3140043a6f0d3db86f78d31f52aff210c137d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 21:25:55 +1200 Subject: Upgrade and adjust config for diff_prune.vim --- vim/after/ftplugin/diff.vim | 7 ++++--- vim/bundle/diff_prune | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/vim/after/ftplugin/diff.vim b/vim/after/ftplugin/diff.vim index a8f77125..ecb651ff 100644 --- a/vim/after/ftplugin/diff.vim +++ b/vim/after/ftplugin/diff.vim @@ -18,9 +18,10 @@ if exists('g:no_plugin_maps') || exists('g:no_diff_maps') endif " Set mappings -nmap p DiffPrune -nmap pp (DiffPrune)l -xmap p DiffPrune +nmap p (DiffPrune) +xmap p (DiffPrune) +nmap pp (DiffPrune)_ let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap p' \ . '|xunmap p' + \ . '|nunmap pp' diff --git a/vim/bundle/diff_prune b/vim/bundle/diff_prune index 3f2fac88..e015502f 160000 --- a/vim/bundle/diff_prune +++ b/vim/bundle/diff_prune @@ -1 +1 @@ -Subproject commit 3f2fac88e3bd4debd263f01dcab90e7eec5a4a67 +Subproject commit e015502fa63ff48ffb0493dd21106b0855f26364 -- cgit v1.2.3 From 7c55b3af50c11069ccf1c4f242444eef4c2c2cf0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 21:39:58 +1200 Subject: Tidy space and backspace mappings --- vim/vimrc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 7a936ba0..ada98de7 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -180,16 +180,12 @@ imap InsertCancel nnoremap FixedJoin mzJ`z nmap J FixedJoin -" Remap normal/visual to scroll down a page +" Remap normal/visual space to scroll down a page, backspace up nnoremap +nnoremap if v:version >= 700 xnoremap -endif - -" Remap normal/visual to scroll up a page -nnoremap -if v:version >= 700 - xnoremap + xnoremap endif " Remap normal/visual & to preserve substitution flags -- cgit v1.2.3 From 6962622d1acc06569e0fe265522820aabfd58bee Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 21:45:22 +1200 Subject: Remove Perl indent string again This is probably fighting too much against the grain, at least for now. --- vim/indent/perl.vim | 137 ---------------------------------------------------- 1 file changed, 137 deletions(-) delete mode 100644 vim/indent/perl.vim diff --git a/vim/indent/perl.vim b/vim/indent/perl.vim deleted file mode 100644 index aac8f818..00000000 --- a/vim/indent/perl.vim +++ /dev/null @@ -1,137 +0,0 @@ -" Custom Vim indent file for Perl5; the stock one didn't suit me. - -" Only load this indent file when no other was loaded. -if exists('b:did_indent') || &compatible - finish -endif -let b:did_indent = 1 - -" Indent settings -setlocal indentexpr=GetPerlIndent(v:lnum) -setlocal indentkeys=o,O,0=,0=},0=),0=],0=&&,0=\|\|,0=//,0=?,0=:, - -" Build patterns for heredoc indenting. Note that we detect indented heredocs -" with tildes like <<~EOF, but we don't treat them any differently. We don't -" strictly match the quotes either, in an effort to keep this fast. -let s:heredoc_word = '\I\i*' -let s:heredoc_open = '<<\~\?' - \ . '\(' - \ . '\\\?' . s:heredoc_word - \ . '\|' - \ . "['`\"]" . s:heredoc_word . "['`\"]" - \ . '\)' - \ . '.*;\s*$' - -" Define indent function -function! GetPerlIndent(lnum) - - " Get previous line, bail if none - let l:pn = prevnonblank(a:lnum - 1) - if !l:pn - return 0 - endif - - " Heredoc and POD flags - let l:heredoc = 0 - let l:pod = 0 - - " Start loop back through up to 512 lines of context - let l:lim = 512 - let l:hpn = a:lnum > l:lim ? a:lnum - l:lim : 0 - while l:hpn < a:lnum - let l:hpl = getline(l:hpn) - - " If we're not in a heredoc and not in a comment ... - if !l:heredoc && l:hpl !~# '^\s*#' - - " POD switching; match any section so that we can handle long PODs - if stridx(l:hpl, '=') == 0 - let l:pod = stridx(l:hpl, '=cut') != 0 - - " Heredoc switch on - else - let l:hpm = matchstr(l:hpl, s:heredoc_open) - if strlen(l:hpm) - let l:heredoc = 1 - let l:hpw = matchstr(l:hpm, s:heredoc_word) - let l:pn = l:hpn - endif - endif - - " If we are in a heredoc and we found the token word, finish it - elseif l:heredoc && l:hpl =~# '^'.l:hpw.'\>' - let l:heredoc = 0 - unlet l:hpw - endif - - " Bump the loop index - let l:hpn = l:hpn + 1 - - endwhile - - " If we ended up in a heredoc, never indent. - if l:heredoc - return 0 - endif - - " If we're in POD, just autoindent; simple and good enough. - if l:pod - return indent(a:lnum - 1) - endif - - " Get data of previous non-blank and non-heredoc line - let l:pl = getline(l:pn) - let l:pi = indent(l:pn) - - " Just follow comment indent - if l:pl =~# '^\s*#' - return l:pi - endif - - " Get current line properties - let l:cl = getline(a:lnum) - - " Get value of 'shiftwidth' - let l:sw = &shiftwidth ? &shiftwidth : &tabstop - - " Base indent with any fractional indent removed - let l:pb = l:pi - l:pi % l:sw - - " Handle open and closing brackets - let l:open = l:pl =~# '[{([]\s*$' - let l:shut = l:cl =~# '^\s*[])}]' - if l:open || l:shut - let l:in = l:pb - if l:open - let l:in = l:in + l:sw - endif - if l:shut - let l:in = l:in - l:sw - endif - return l:in > 0 ? l:in : 0 - endif - - " Never continue after a semicolon or a double-underscore - if l:pl =~# '\;\s*$' - \ || l:pl =~# '__DATA__' - \ || l:pl =~# '__END__' - return l:pb - - " Line continuation hints - elseif l:cl =~# '^\s*\(and\|or\|xor\)' - \ || l:cl =~# '^\s*\(&&\|||\|//\)' - \ || l:cl =~# '^\s*[?:=]' - return l:pb + l:sw / 2 - - " Default to indent of previous line - else - return l:pb - - endif - -endfunction - -" How to undo all of that -let b:undo_indent = 'setlocal indentexpr<' - \ . '|setlocal indentkeys<' - \ . '|delfunction GetPerlIndent' -- cgit v1.2.3 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(-) 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 From 7769210cdfe0c90fefe01fca1199f526c6871a00 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 23:14:01 +1200 Subject: Change local leader back to comma Double-backslash had a major problem--if there was no local mapping defined, you ended up loading the global one. --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index ada98de7..312b982f 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -9,7 +9,7 @@ runtime system.vim " Load filetype settings, plugins, and maps if has('autocmd') - let g:maplocalleader = '\\' + let g:maplocalleader = ',' filetype plugin indent on endif -- cgit v1.2.3 From 950f883d89ca0fa7e80cca8f9a0d8cfbade8ebc3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 01:15:22 +1200 Subject: Overhaul ftplugin check, lint, tidy - Set 'equalprg' for HTML and Perl - Discard filter#Stable() - Set default :compiler for all applicable filetypes - Change local leader mappings for Perl and shell script merely to set :compiler, rather than running it - Bind global leader mapping for running :lmake! - Bind global leader mappings for applying 'equalprg' and 'formatprg' to the whole buffer, using a new autoloaded helper function vimrc#Anchor() to avoid the cursor jumping around --- vim/after/ftplugin/gitcommit.vim | 10 +++------- vim/after/ftplugin/html.vim | 24 ++++++++++++++---------- vim/after/ftplugin/perl.vim | 17 +++++++++++------ vim/after/ftplugin/php.vim | 12 ++++++------ vim/after/ftplugin/sh.vim | 21 ++++++++++++--------- vim/after/ftplugin/vim.vim | 12 ++++++------ vim/after/ftplugin/zsh.vim | 13 ++++--------- vim/autoload/compiler.vim | 33 --------------------------------- vim/autoload/filter.vim | 7 ------- vim/autoload/vimrc.vim | 6 ++++++ vim/vimrc | 7 +++++++ 11 files changed, 69 insertions(+), 93 deletions(-) delete mode 100644 vim/autoload/compiler.vim delete mode 100644 vim/autoload/filter.vim create mode 100644 vim/autoload/vimrc.vim diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index 035b835c..e55ebff7 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -6,10 +6,6 @@ endif " Make angle brackets behave like mail quotes setlocal comments+=n:> setlocal formatoptions+=coqr - -" Add to undo script -if exists('b:undo_ftplugin') - let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments<' - \ . '|setlocal formatoptions<' -endif +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal comments<' + \ . '|setlocal formatoptions<' diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim index 545076b1..3a08d110 100644 --- a/vim/after/ftplugin/html.vim +++ b/vim/after/ftplugin/html.vim @@ -3,11 +3,21 @@ if &filetype != 'html' || &compatible || v:version < 700 finish endif +" Use tidy(1) for checking and program formatting +compiler tidy +setlocal equalprg=tidy\ -quiet +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal equalprg<' + \ . '|setlocal errorformat<' + \ . '|setlocal makeprg<' + " Set up hooks for timestamp updating -autocmd html_timestamp BufWritePre - \ if exists('b:html_timestamp_check') - \| call html#TimestampUpdate() - \|endif +augroup html_timestamp + autocmd BufWritePre + \ if exists('b:html_timestamp_check') + \| call html#TimestampUpdate() + \|endif +augroup END let b:undo_ftplugin = b:undo_ftplugin \ . '|autocmd! html_timestamp BufWritePre ' @@ -17,13 +27,7 @@ if exists('g:no_plugin_maps') || exists('g:no_html_maps') endif " Set mappings -nnoremap l - \ :call compiler#Make('tidy') nnoremap r \ :call html#UrlLink() -nnoremap t - \ :call filter#Stable('tidy -quiet') let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap l' \ . '|nunmap r' - \ . '|nunmap t' diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim index 8887b56a..564653d2 100644 --- a/vim/after/ftplugin/perl.vim +++ b/vim/after/ftplugin/perl.vim @@ -3,22 +3,27 @@ if &filetype != 'perl' || &compatible || v:version < 700 finish endif +" Use Perl itself for checking and Perl::Tidy for tidying +compiler perl +setlocal equalprg=perltidy +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal equalprg<' + \ . '|setlocal errorformat<' + \ . '|setlocal makeprg<' + " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_perl_maps') finish endif -" Set mappings +" Mappings to choose compiler nnoremap c - \ :call compiler#Make('perl') + \ :compiler perl nnoremap l - \ :call compiler#Make('perlcritic') -nnoremap t - \ :call filter#Stable('perltidy') + \ :compiler perlcritic let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap c' \ . '|nunmap l' - \ . '|nunmap t' " Bump version numbers nmap v diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim index 35849ac5..1f40aba7 100644 --- a/vim/after/ftplugin/php.vim +++ b/vim/after/ftplugin/php.vim @@ -3,6 +3,12 @@ if &filetype != 'php' || &compatible || v:version < 700 finish endif +" Use PHP itself for syntax checking +compiler php +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal errorformat<' + \ . '|setlocal makeprg<' + " Set comment formats setlocal comments=s1:/*,m:*,ex:*/,://,:# setlocal formatoptions+=or @@ -15,12 +21,6 @@ if exists('g:no_plugin_maps') || exists('g:no_php_maps') finish endif -" Set mappings -nnoremap c - \ :call compiler#Make('php') -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap c' - " Get rid of the core ftplugin's square-bracket maps on unload let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap [[' diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim index 086e23d5..01505a88 100644 --- a/vim/after/ftplugin/sh.vim +++ b/vim/after/ftplugin/sh.vim @@ -17,11 +17,6 @@ if exists('b:is_bash') \ . '|setlocal keywordprg<' endif -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_sh_maps') - finish -endif - " Choose check compiler based on file subtype if exists('b:is_bash') let b:sh_check_compiler = 'bash' @@ -30,14 +25,22 @@ elseif exists('b:is_kornshell') else let b:sh_check_compiler = 'sh' endif +execute 'compiler '.b:sh_check_compiler let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:sh_check_compiler' + \ . '|setlocal errorformat<' + \ . '|setlocal makeprg<' + +" Stop here if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_sh_maps') + finish +endif -" Set mappings -nnoremap c - \ :call compiler#Make(b:sh_check_compiler) +" Mappings to choose compiler +nnoremap c + \ ':compiler '.b:sh_check_compiler.'' nnoremap l - \ :call compiler#Make('shellcheck') + \ :compiler shellcheck let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap c' \ . '|nunmap l' diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim index e01e2050..bd0a83ce 100644 --- a/vim/after/ftplugin/vim.vim +++ b/vim/after/ftplugin/vim.vim @@ -3,17 +3,17 @@ if &filetype != 'vim' || &compatible || v:version < 700 finish endif +" Use Vint as a syntax checker +compiler vint +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal errorformat<' + \ . '|setlocal makeprg<' + " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_vim_maps') finish endif -" Set mappings -nnoremap l - \ :call compiler#Make('vint') -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap l' - " Get rid of the core ftplugin's square-bracket maps on unload let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap [[' diff --git a/vim/after/ftplugin/zsh.vim b/vim/after/ftplugin/zsh.vim index 79f3c638..d5852e53 100644 --- a/vim/after/ftplugin/zsh.vim +++ b/vim/after/ftplugin/zsh.vim @@ -3,13 +3,8 @@ if &filetype != 'zsh' || &compatible || v:version < 700 finish endif -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_zsh_maps') - finish -endif - -" Set mappings -nnoremap c - \ :call compiler#Make('zsh') +" Use Z shell itself as a syntax checker +compiler zsh let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap c' + \ . '|setlocal errorformat<' + \ . '|setlocal makeprg<' diff --git a/vim/autoload/compiler.vim b/vim/autoload/compiler.vim deleted file mode 100644 index b4bf66b6..00000000 --- a/vim/autoload/compiler.vim +++ /dev/null @@ -1,33 +0,0 @@ -" Run a compiler check (:lmake, :lwindow) without trampling over previous -" settings, by temporarily loading the compiler with the given name -function! compiler#Make(compiler) abort - - " Save the given compiler or failing that the current 'makeprg' and - " 'errorformat' values - if exists('b:current_compiler') - let l:save_compiler = b:current_compiler - else - let l:save_makeprg = &makeprg - let l:save_errorformat = &errorformat - endif - - " Choose the compiler - execute 'compiler ' . a:compiler - - " Run the 'makeprg' with results in location list - lmake! - - " If we saved a compiler, switch back to it, otherwise restore the previous - " values for 'makeprg' and 'errorformat' - if exists('l:save_compiler') - execute 'compiler ' . l:save_compiler - else - unlet! b:current_compiler - let &l:makeprg = l:save_makeprg - let &l:errorformat = l:save_errorformat - endif - - " Show location list - lwindow - -endfunction diff --git a/vim/autoload/filter.vim b/vim/autoload/filter.vim deleted file mode 100644 index 0a39f23a..00000000 --- a/vim/autoload/filter.vim +++ /dev/null @@ -1,7 +0,0 @@ -" Run a filter over the entire buffer, but save the window position and -" restore it after doing so -function! filter#Stable(command) abort - let l:view = winsaveview() - execute '%!' . a:command - call winrestview(l:view) -endfunction diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim new file mode 100644 index 00000000..0dff8ffd --- /dev/null +++ b/vim/autoload/vimrc.vim @@ -0,0 +1,6 @@ +" Run some normal-mode keystrokes without jumping around +function! vimrc#Anchor(keys) abort + let l:view = winsaveview() + execute 'normal! '.a:keys + call winrestview(l:view) +endfunction diff --git a/vim/vimrc b/vim/vimrc index 312b982f..c08ec677 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -285,6 +285,13 @@ nnoremap y :registers " \z sets NZ English spelling (compare \u) nnoremap z :setlocal spelllang=en_nz +" \= runs the whole buffer through =, preserving position +nnoremap = :call vimrc#Anchor('1G=G') +" \+ runs the whole buffer through gq, preserving position +nnoremap + :call vimrc#Anchor('1GgqG') +" \. runs the configured make program to location list +nnoremap . :lmake! + " \DEL deletes the current buffer nnoremap :bdelete " \INS edits a new buffer -- cgit v1.2.3 From c63915c829affced69f20d0ea0bcd32a71088d68 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 01:41:50 +1200 Subject: Revert :setglobal changes I thought that global options were the defaults for local options for new buffers, but that does not seem to be the case. Instead, reload the filetype for the active buffer in the reload guard. I wonder what the point of :setglobal even is? --- vim/vimrc | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index c08ec677..199dd85b 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -32,15 +32,15 @@ if has('syntax') && !exists('g:syntax_on') endif " The all-important default indent settings; filetypes to tweak -setglobal autoindent " Use indent of previous line on new lines -setglobal expandtab " Use spaces instead of tabs -setglobal shiftwidth=4 " Indent with four spaces +set autoindent " Use indent of previous line on new lines +set expandtab " Use spaces instead of tabs +set shiftwidth=4 " Indent with four spaces " Spaces to insert on Tab key insert if v:version > 703 || v:version == 703 && has('patch693') - setglobal softtabstop=-1 " Refer to 'shiftwidth' if supported + set softtabstop=-1 " Refer to 'shiftwidth' if supported else - setglobal softtabstop=4 " Otherwise just four spaces + set softtabstop=4 " Otherwise just four spaces endif " Let me backspace over pretty much anything @@ -69,14 +69,14 @@ endif " Delete comment leaders when joining lines, if supported if v:version > 703 || v:version == 703 && has('patch541') - setglobal formatoptions+=j + set formatoptions+=j endif " Keep more command and search history set history=500 " Don't assume I'm editing C; let the filetype set this -setglobal include= +set include= " Don't join lines with two spaces at the end of sentences set nojoinspaces @@ -99,13 +99,13 @@ if v:version >= 700 endif " Add angle brackets to pairs of matched characters -setglobal matchpairs+=<:> +set matchpairs+=<:> " Don't allow setting options via buffer content -setglobal nomodeline +set nomodeline " Treat numbers with a leading zero as decimal, not octal -setglobal nrformats-=octal +set nrformats-=octal " Abbreviate some more regularly displayed messages set shortmess+=I " Don't show startup splash screen @@ -115,7 +115,7 @@ set shortmess+=w " written -> [w], appended -> [a] " Clear default 'comments' value, let the filetype handle it if has('comments') - setglobal comments= + set comments= endif " Highlight settings for search @@ -127,7 +127,7 @@ endif " More sensible language-agnostic setting for gf/:find if has('file_in_path') - setglobal path=.,,** + set path=.,,** endif " Don't load GUI menus; set here before GUI starts @@ -137,10 +137,10 @@ endif " Line break behaviour settings for 'wrap' if has('linebreak') - setglobal linebreak " Break lines at word boundaries - set showbreak=... " Prefix wrapped rows with three dots + set linebreak " Break lines at word boundaries + set showbreak=... " Prefix wrapped rows with three dots if exists('+breakindent') - setglobal breakindent " Indent wrapped lines, if supported + set breakindent " Indent wrapped lines, if supported endif endif @@ -300,10 +300,14 @@ nnoremap :enew " Source any .vim files from ~/.vim/config runtime! config/*.vim -" Flag that we loaded, tell the user if we reload -if 1 - if exists('g:loaded_vimrc') - echomsg 'Reloaded vimrc: '.$MYVIMRC +" If we reloaded, reload filetype detection for the active buffer too, so that +" any local settings for it are restored +if exists('g:loaded_vimrc') + if &filetype != '' + doautocmd filetypedetect BufRead endif + echomsg 'Reloaded vimrc: '.$MYVIMRC +endif +if 1 let g:loaded_vimrc = 1 endif -- cgit v1.2.3 From f5d909b640142a1198b0d26ae5604dc636f72d04 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 02:10:44 +1200 Subject: Use !=# for &filetype match --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index 199dd85b..3678e375 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -303,7 +303,7 @@ runtime! config/*.vim " If we reloaded, reload filetype detection for the active buffer too, so that " any local settings for it are restored if exists('g:loaded_vimrc') - if &filetype != '' + if &filetype !=# '' doautocmd filetypedetect BufRead endif echomsg 'Reloaded vimrc: '.$MYVIMRC -- cgit v1.2.3 From 4054ecb07c13954fa3f74092bb09ce1b72711537 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 02:14:41 +1200 Subject: Tweak HTML indenting to indent after

--- vim/indent/html.vim | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 vim/indent/html.vim diff --git a/vim/indent/html.vim b/vim/indent/html.vim new file mode 100644 index 00000000..b0a4a4f6 --- /dev/null +++ b/vim/indent/html.vim @@ -0,0 +1,2 @@ +" Indent after

paragraph tags too +let g:html_indent_inctags = 'p' -- cgit v1.2.3 From 576505dba94005662b8fd1293ab0d1a33d8e396d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 02:28:49 +1200 Subject: Specify which Vim to run in Makefile --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4556ceae..c879db4c 100644 --- a/Makefile +++ b/Makefile @@ -492,6 +492,7 @@ install-urxvt: urxvt/ext/select find urxvt/ext -type f ! -name '*.pl' \ -exec cp -p -- {} $(HOME)/.urxvt/ext \; +VIM = vim VIMDIR = $(HOME)/.vim VIMRC = $(HOME)/.vimrc @@ -507,6 +508,7 @@ install-vim: install-vim-after \ install-neovim: make install-vim \ + VIM=nvim \ VIMDIR=$${XDG_CONFIG_HOME:-"$$HOME"/.config}/nvim \ VIMRC=$${XDF_CONFIG_HOME:="$$HOME"/.config}/init.vim @@ -542,7 +544,7 @@ install-vim-bundle: install-vim-config find vim/bundle/*/*/* \ -type f -exec sh -c \ 'cp -p -- "$$1" $(VIMDIR)/"$${1#vim/bundle/*/}"' _ {} \; - vim -e -u NONE -c 'helptags $(VIMDIR)/doc' -c quit + $(VIM) -e -u NONE -c 'helptags $(VIMDIR)/doc' -c quit install-vim-compiler: mkdir -p -- $(VIMDIR)/compiler -- cgit v1.2.3 From ce0673e08850785842b3caddd51382399768e8ed Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 02:34:46 +1200 Subject: Adjust comments in filetype.vim --- vim/filetype.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vim/filetype.vim b/vim/filetype.vim index 440ee6e1..89ee5b7d 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -42,7 +42,8 @@ function! s:StripRepeat() endfunction -" Check if the first line is a shebang +" Check whether the first line was changed and looks like a shebang, and if +" so, re-run filetype detection function! s:CheckShebang() if line('''[') == 1 && stridx(getline(1), '#!') == 0 doautocmd filetypedetect BufRead @@ -517,8 +518,9 @@ augroup filetypedetect \| runtime scripts.vim \|endif - " If supported, on leaving insert mode, check whether the first line was " - " changed and is a shebang format, and if so, re-run filetype detection + " If supported, on leaving insert mode, check whether the first line was + " changed and looks like a shebang format, and if so, re-run filetype + " detection if v:version > 700 autocmd InsertLeave * call s:CheckShebang() endif -- cgit v1.2.3 From 9ede911cc92a224419e034b81e8c3abf4cdf9119 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 03:08:24 +1200 Subject: Clear b:current_compiler on unload --- vim/after/ftplugin/html.vim | 1 + vim/after/ftplugin/perl.vim | 1 + vim/after/ftplugin/php.vim | 1 + vim/after/ftplugin/sh.vim | 1 + vim/after/ftplugin/vim.vim | 1 + vim/after/ftplugin/zsh.vim | 1 + 6 files changed, 6 insertions(+) diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim index 3a08d110..d0625fb7 100644 --- a/vim/after/ftplugin/html.vim +++ b/vim/after/ftplugin/html.vim @@ -7,6 +7,7 @@ endif compiler tidy setlocal equalprg=tidy\ -quiet let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:current_compiler' \ . '|setlocal equalprg<' \ . '|setlocal errorformat<' \ . '|setlocal makeprg<' diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim index 564653d2..c17ebb56 100644 --- a/vim/after/ftplugin/perl.vim +++ b/vim/after/ftplugin/perl.vim @@ -7,6 +7,7 @@ endif compiler perl setlocal equalprg=perltidy let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:current_compiler' \ . '|setlocal equalprg<' \ . '|setlocal errorformat<' \ . '|setlocal makeprg<' diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim index 1f40aba7..765c1fb9 100644 --- a/vim/after/ftplugin/php.vim +++ b/vim/after/ftplugin/php.vim @@ -6,6 +6,7 @@ endif " Use PHP itself for syntax checking compiler php let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:current_compiler' \ . '|setlocal errorformat<' \ . '|setlocal makeprg<' diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim index 01505a88..5cafdd70 100644 --- a/vim/after/ftplugin/sh.vim +++ b/vim/after/ftplugin/sh.vim @@ -27,6 +27,7 @@ else 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<' diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim index bd0a83ce..2d11b2d6 100644 --- a/vim/after/ftplugin/vim.vim +++ b/vim/after/ftplugin/vim.vim @@ -6,6 +6,7 @@ endif " Use Vint as a syntax checker compiler vint let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:current_compiler' \ . '|setlocal errorformat<' \ . '|setlocal makeprg<' diff --git a/vim/after/ftplugin/zsh.vim b/vim/after/ftplugin/zsh.vim index d5852e53..8a27846b 100644 --- a/vim/after/ftplugin/zsh.vim +++ b/vim/after/ftplugin/zsh.vim @@ -6,5 +6,6 @@ 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<' -- cgit v1.2.3 From 8cfc6a44ebfa067a6283c1627a3b76583ef3dff9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 03:09:30 +1200 Subject: Don't defer package load for matchit --- vim/plugin/matchit.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/plugin/matchit.vim b/vim/plugin/matchit.vim index 31e6e37d..4507640e 100644 --- a/vim/plugin/matchit.vim +++ b/vim/plugin/matchit.vim @@ -1,6 +1,6 @@ " Get matchit.vim, one way or another if has('packages') && !has('nvim') - packadd! matchit + packadd matchit else silent! runtime macros/matchit.vim endif -- cgit v1.2.3 From ad0a1fdec64ba686d6e75738755cf4d3b5b03e8d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 14:12:03 +1200 Subject: Adjust comment on scripts.vim load --- vim/filetype.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vim/filetype.vim b/vim/filetype.vim index 89ee5b7d..6bb52b96 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -509,9 +509,9 @@ augroup filetypedetect \| call s:StripRepeat() \|endif - " If we *still* don't have a filetype, run the scripts.vim file that will - " examine actual file contents--but only the first one; don't load the - " system one at all + " If we still don't have a filetype, run the scripts.vim file that performs + " cleverer checks including looking at actual file contents--but only my + " custom one; don't load the system one at all. autocmd BufNewFile,BufRead,StdinReadPost \ * \ if !did_filetype() -- cgit v1.2.3 From 84c5cd6551c5f4df4974896670c83ef7f73dd374 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 14:16:06 +1200 Subject: Add extra Perl file detection rules --- Makefile | 6 ++++++ vim/ftdetect/perl.vim | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 vim/ftdetect/perl.vim diff --git a/Makefile b/Makefile index c879db4c..e3e0ad38 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,7 @@ install-vim-compiler \ install-vim-config \ install-vim-filetype \ + install-vim-ftdetect \ install-vim-ftplugin \ install-vim-gui \ install-vim-gui-config \ @@ -502,6 +503,7 @@ install-vim: install-vim-after \ install-vim-compiler \ install-vim-config \ install-vim-filetype \ + install-vim-ftdetect \ install-vim-ftplugin \ install-vim-indent \ install-vim-plugin @@ -561,6 +563,10 @@ install-vim-config: install-vim-filetype: cp -p -- vim/filetype.vim vim/scripts.vim $(VIMDIR) +install-vim-ftdetect: + mkdir -p -- $(VIMDIR)/ftdetect + cp -p -- vim/ftdetect/*.vim $(VIMDIR)/ftdetect + install-vim-ftplugin: mkdir -p -- $(VIMDIR)/ftplugin cp -p -- vim/ftplugin/*.vim $(VIMDIR)/ftplugin diff --git a/vim/ftdetect/perl.vim b/vim/ftdetect/perl.vim new file mode 100644 index 00000000..8b2e1b4e --- /dev/null +++ b/vim/ftdetect/perl.vim @@ -0,0 +1,9 @@ +" If it's a new file in a bin, libexec, or scripts subdir that has a +" Makefile.PL, it's almost definitely Perl. +autocmd BufNewFile + \ */bin/* + \,*/libexec/* + \,*/scripts/* + \ if filereadable(expand(':p:h:h') . '/Makefile.PL') + \| setfiletype perl + \|endif -- cgit v1.2.3 From 5436627ce24e278915e088f6fc5fcf69836282d2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 15:47:05 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 423aa0de..4be13693 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v1.24.0 -Sun Jul 8 04:20:25 UTC 2018 +tejr dotfiles v1.25.0 +Mon Jul 9 03:46:58 UTC 2018 -- cgit v1.2.3