From 9015b6d8c391ca3974b5a9121031f50525ecb12c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 17 Jun 2018 11:52:57 +1200 Subject: Add local copy of php.vim compiler Slightly adapted; doesn't load at all if &compatible --- vim/compiler/php.vim | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 vim/compiler/php.vim diff --git a/vim/compiler/php.vim b/vim/compiler/php.vim new file mode 100644 index 00000000..aeb171c5 --- /dev/null +++ b/vim/compiler/php.vim @@ -0,0 +1,23 @@ +if exists('g:current_compiler') || &compatible + finish +endif +let g:current_compiler = 'php' + +if exists(':CompilerSet') != 2 + command -nargs=* CompilerSet setlocal +endif + +" 7.4.191 is the earliest version with the :S file name modifier, which we +" really should use if we can +if v:version >= 704 || v:version == 704 && has('patch191') + CompilerSet makeprg=php\ -lq\ %:S +else + CompilerSet makeprg=php\ -lq\ % +endif + +" Here be copy-pasted dragons +CompilerSet errorformat=%E%.%#Parse\ error:\ %m\ in\ %f\ on\ line\ %l, + \%W%.%#Notice:\ %m\ in\ %f\ on\ line\ %l, + \%E%.%#Parse\ error:\ %m\ in\ %f\ on\ line\ %l, + \%W%.%#Notice:\ %m\ in\ %f\ on\ line\ %l, + \%-G%.%# -- cgit v1.2.3 From 670c735799879ae066b9a5249356a4d872514951 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 17 Jun 2018 11:53:31 +1200 Subject: Use autoload function for temp-makeprg :lmake --- Makefile | 5 +++++ vim/after/ftplugin/html/lint.vim | 25 ++++++------------------- vim/after/ftplugin/perl/check.vim | 25 ++++++------------------- vim/after/ftplugin/perl/lint.vim | 25 ++++++------------------- vim/after/ftplugin/php/check.vim | 34 ++++++---------------------------- vim/after/ftplugin/sh/check.vim | 36 +++++++++++++----------------------- vim/after/ftplugin/sh/lint.vim | 25 ++++++------------------- vim/after/ftplugin/vim/lint.vim | 25 ++++++------------------- vim/after/ftplugin/zsh/check.vim | 25 ++++++------------------- vim/autoload/compiler.vim | 11 +++++++++++ 10 files changed, 71 insertions(+), 165 deletions(-) create mode 100644 vim/autoload/compiler.vim diff --git a/Makefile b/Makefile index 02030e7a..b66b4aa0 100644 --- a/Makefile +++ b/Makefile @@ -495,6 +495,7 @@ VIMDIR = $(HOME)/.vim VIMRC = $(HOME)/.vimrc install-vim: install-vim-after \ + install-vim-autoload \ install-vim-bundle \ install-vim-compiler \ install-vim-config \ @@ -526,6 +527,10 @@ install-vim-after-syntax: mkdir -p $(VIMDIR)/after/syntax cp -p -- vim/after/syntax/*.vim $(VIMDIR)/after/syntax +install-vim-autoload: + mkdir -p -- $(VIMDIR)/autoload + cp -p -- vim/autoload/*.vim $(VIMDIR)/autoload + install-vim-bundle: install-vim-config find vim/bundle/*/* \ -type d -exec sh -c \ diff --git a/vim/after/ftplugin/html/lint.vim b/vim/after/ftplugin/html/lint.vim index a3776d60..0b56e73c 100644 --- a/vim/after/ftplugin/html/lint.vim +++ b/vim/after/ftplugin/html/lint.vim @@ -15,33 +15,20 @@ if &filetype !=# 'html' finish endif +" Don't load if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_html_maps') + finish +endif + " Flag as loaded let b:did_ftplugin_html_lint = 1 let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_html_lint' -" Build function for linter -function! s:HtmlLint() - if exists('b:current_compiler') - let l:save_compiler = b:current_compiler - endif - compiler tidy - lmake! - lwindow - if exists('l:save_compiler') - execute 'compiler ' . l:save_compiler - endif -endfunction - -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_html_maps') - finish -endif - " Define a mapping target nnoremap \ HtmlLint - \ :call HtmlLint() + \ :call compiler#Make('tidy') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap HtmlLint' diff --git a/vim/after/ftplugin/perl/check.vim b/vim/after/ftplugin/perl/check.vim index e115b37f..f6f99f08 100644 --- a/vim/after/ftplugin/perl/check.vim +++ b/vim/after/ftplugin/perl/check.vim @@ -10,33 +10,20 @@ if exists('b:did_ftplugin_perl_check') finish endif +" Don't load if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_perl_maps') + finish +endif + " Flag as loaded let b:did_ftplugin_perl_check = 1 let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_perl_check' -" Build function for checker -function! s:PerlCheck() - if exists('b:current_compiler') - let l:save_compiler = b:current_compiler - endif - compiler perl - lmake! - lwindow - if exists('l:save_compiler') - execute 'compiler ' . l:save_compiler - endif -endfunction - -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_perl_maps') - finish -endif - " Define a mapping target nnoremap \ PerlCheck - \ :call PerlCheck() + \ :call compiler#Make('perl') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap PerlCheck' diff --git a/vim/after/ftplugin/perl/lint.vim b/vim/after/ftplugin/perl/lint.vim index 3e73ac9a..eaa6684c 100644 --- a/vim/after/ftplugin/perl/lint.vim +++ b/vim/after/ftplugin/perl/lint.vim @@ -10,33 +10,20 @@ if exists('b:did_ftplugin_perl_lint') finish endif +" Don't load if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_html_maps') + finish +endif + " Flag as loaded let b:did_ftplugin_perl_lint = 1 let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_perl_lint' -" Build function for linter -function! s:PerlLint() - if exists('b:current_compiler') - let l:save_compiler = b:current_compiler - endif - compiler perlcritic - lmake! - lwindow - if exists('l:save_compiler') - execute 'compiler ' . l:save_compiler - endif -endfunction - -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_perl_maps') - finish -endif - " Define a mapping target nnoremap \ PerlLint - \ :call PerlLint() + \ :call compiler#Make('perlcritic') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap PerlLint' diff --git a/vim/after/ftplugin/php/check.vim b/vim/after/ftplugin/php/check.vim index f211a642..9dc4c6a8 100644 --- a/vim/after/ftplugin/php/check.vim +++ b/vim/after/ftplugin/php/check.vim @@ -10,42 +10,20 @@ if exists('b:did_ftplugin_php_check') finish endif +" Don't load if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_php_maps') + finish +endif + " Flag as loaded let b:did_ftplugin_php_check = 1 let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_php_check' -" Build function for checker -function! s:PhpCheck() - if exists('b:current_compiler') - let l:save_compiler = b:current_compiler - endif - compiler php - - " The PHP compiler is unusual: it gets us to provide the filename argument - " ourselves. 7.4.191 is the earliest version with the :S file name modifier, - " which we really should use if we can - if v:version >= 704 || v:version == 704 && has('patch191') - lmake! %:S - else - lmake! % - endif - lwindow - - if exists('l:save_compiler') - execute 'compiler ' . l:save_compiler - endif -endfunction - -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_php_maps') - finish -endif - " Define a mapping target nnoremap \ PhpCheck - \ :call PhpCheck() + \ :call compiler#Make('php') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap PhpCheck' diff --git a/vim/after/ftplugin/sh/check.vim b/vim/after/ftplugin/sh/check.vim index e92409cf..499926f3 100644 --- a/vim/after/ftplugin/sh/check.vim +++ b/vim/after/ftplugin/sh/check.vim @@ -10,39 +10,29 @@ if exists('b:did_ftplugin_sh_check') finish endif +" Stop here if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_sh_maps') + finish +endif + " Flag as loaded let b:did_ftplugin_sh_check = 1 let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_sh_check' -" Build function for checker -function! s:ShCheck() - if exists('b:current_compiler') - let l:save_compiler = b:current_compiler - endif - if exists('b:is_bash') - compiler bash - elseif exists('b:is_kornshell') - compiler ksh - else - compiler sh - endif - lmake! - lwindow - if exists('l:save_compiler') - execute 'compiler ' . l:save_compiler - endif -endfunction - -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_sh_maps') - finish +" Choose compiler based on file subtype +if exists('b:is_bash') + let b:sh_check_compiler = 'bash' +elseif exists('b:is_kornshell') + let b:sh_check_compiler = 'ksh' +else + let b:sh_check_compiler = 'sh' endif " Define a mapping target nnoremap \ ShCheck - \ :call ShCheck() + \ :call compiler#Make(b:sh_check_compiler) let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap ShCheck' diff --git a/vim/after/ftplugin/sh/lint.vim b/vim/after/ftplugin/sh/lint.vim index 87f1c07e..65fe003d 100644 --- a/vim/after/ftplugin/sh/lint.vim +++ b/vim/after/ftplugin/sh/lint.vim @@ -10,33 +10,20 @@ if exists('b:did_ftplugin_sh_lint') finish endif +" Don't load if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_sh_maps') + finish +endif + " Flag as loaded let b:did_ftplugin_sh_lint = 1 let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_sh_lint' -" Build function for linter -function! s:ShLint() - if exists('b:current_compiler') - let l:save_compiler = b:current_compiler - endif - compiler shellcheck - lmake! - lwindow - if exists('l:save_compiler') - execute 'compiler ' . l:save_compiler - endif -endfunction - -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_sh_maps') - finish -endif - " Define a mapping target nnoremap \ ShLint - \ :call ShLint() + \ :call compiler#Make('shellcheck') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap ShLint' diff --git a/vim/after/ftplugin/vim/lint.vim b/vim/after/ftplugin/vim/lint.vim index 1e4f7d39..bd8c1da4 100644 --- a/vim/after/ftplugin/vim/lint.vim +++ b/vim/after/ftplugin/vim/lint.vim @@ -10,33 +10,20 @@ if exists('b:did_ftplugin_vim_lint') finish endif +" Don't load if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_vim_maps') + finish +endif + " Flag as loaded let b:did_ftplugin_vim_lint = 1 let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_vim_lint' -" Build function for linter -function! s:VimLint() - if exists('b:current_compiler') - let l:save_compiler = b:current_compiler - endif - compiler vint - lmake! - lwindow - if exists('l:save_compiler') - execute 'compiler ' . l:save_compiler - endif -endfunction - -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_vim_maps') - finish -endif - " Define a mapping target nnoremap \ VimLint - \ :call VimLint() + \ :call compiler#Make('vint') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap VimLint' diff --git a/vim/after/ftplugin/zsh/check.vim b/vim/after/ftplugin/zsh/check.vim index 1d327a62..3e5ad7c6 100644 --- a/vim/after/ftplugin/zsh/check.vim +++ b/vim/after/ftplugin/zsh/check.vim @@ -10,33 +10,20 @@ if exists('b:did_ftplugin_zsh_check') finish endif +" Don't load if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_zsh_maps') + finish +endif + " Flag as loaded let b:did_ftplugin_zsh_check = 1 let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_zsh_check' -" Build function for checker -function! s:ZshCheck() - if exists('b:current_compiler') - let l:save_compiler = b:current_compiler - endif - compiler zsh - lmake! - lwindow - if exists('l:save_compiler') - execute 'compiler ' . l:save_compiler - endif -endfunction - -" Set up a mapping for the checker, if we're allowed -if exists('g:no_plugin_maps') || exists('g:no_zsh_maps') - finish -endif - " Define a mapping target nnoremap \ ZshCheck - \ :call ZshCheck() + \ :call compiler#Make('zsh') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap ZshCheck' diff --git a/vim/autoload/compiler.vim b/vim/autoload/compiler.vim new file mode 100644 index 00000000..37e46275 --- /dev/null +++ b/vim/autoload/compiler.vim @@ -0,0 +1,11 @@ +function! compiler#Make(compiler) abort + if exists('b:current_compiler') + let l:save_compiler = b:current_compiler + endif + execute 'compiler ' . a:compiler + lmake! + lwindow + if exists('l:save_compiler') + execute 'compiler ' . l:save_compiler + endif +endfunction -- cgit v1.2.3 From 1b5501a233c9449f04951b43adea6330d3394d64 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 17 Jun 2018 12:07:14 +1200 Subject: Refine compiler#Make() function --- vim/autoload/compiler.vim | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/vim/autoload/compiler.vim b/vim/autoload/compiler.vim index 37e46275..b4bf66b6 100644 --- a/vim/autoload/compiler.vim +++ b/vim/autoload/compiler.vim @@ -1,11 +1,33 @@ +" 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! - lwindow + + " 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 -- cgit v1.2.3 From d6add13a718e260b27a54c80d840f46206faf95d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 17 Jun 2018 15:00:23 +1200 Subject: Use autoload function for tidy filters --- vim/after/ftplugin/html/tidy.vim | 19 ++++++------------- vim/after/ftplugin/perl/tidy.vim | 19 ++++++------------- vim/autoload/filter.vim | 7 +++++++ 3 files changed, 19 insertions(+), 26 deletions(-) create mode 100644 vim/autoload/filter.vim diff --git a/vim/after/ftplugin/html/tidy.vim b/vim/after/ftplugin/html/tidy.vim index 5a8ded7e..3faefcb7 100644 --- a/vim/after/ftplugin/html/tidy.vim +++ b/vim/after/ftplugin/html/tidy.vim @@ -15,27 +15,20 @@ if &filetype !=# 'html' finish endif +" Don't load if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_html_maps') + finish +endif + " Flag as loaded let b:did_ftplugin_html_tidy = 1 let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_html_tidy' -" Plugin function -function s:HtmlTidy() - let l:view = winsaveview() - %!tidy -quiet - call winrestview(l:view) -endfunction - -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_html_maps') - finish -endif - " Define a mapping target nnoremap \ HtmlTidy - \ :call HtmlTidy() + \ :call filter#Stable('tidy -quiet') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap HtmlTidy' diff --git a/vim/after/ftplugin/perl/tidy.vim b/vim/after/ftplugin/perl/tidy.vim index f6744f3a..64f0eda2 100644 --- a/vim/after/ftplugin/perl/tidy.vim +++ b/vim/after/ftplugin/perl/tidy.vim @@ -10,27 +10,20 @@ if exists('b:did_ftplugin_perl_tidy') finish endif +" Don't load if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_perl_maps') + finish +endif + " Flag as loaded let b:did_ftplugin_perl_tidy = 1 let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_perl_tidy' -" Plugin function -function s:PerlTidy() - let l:view = winsaveview() - %!perltidy - call winrestview(l:view) -endfunction - -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_perl_maps') - finish -endif - " Define a mapping target nnoremap \ PerlTidy - \ :call PerlTidy() + \ :call filter#Stable('perltidy') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap PerlTidy' diff --git a/vim/autoload/filter.vim b/vim/autoload/filter.vim new file mode 100644 index 00000000..f499f432 --- /dev/null +++ b/vim/autoload/filter.vim @@ -0,0 +1,7 @@ +" 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 -- cgit v1.2.3 From 2cdb54026a350755e57e1575e5d7f2ff3b3f05d1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 17 Jun 2018 16:01:46 +1200 Subject: Update insert_suspend_hlsearch.vim --- vim/bundle/insert_suspend_hlsearch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/insert_suspend_hlsearch b/vim/bundle/insert_suspend_hlsearch index 7dc6de6d..6f117331 160000 --- a/vim/bundle/insert_suspend_hlsearch +++ b/vim/bundle/insert_suspend_hlsearch @@ -1 +1 @@ -Subproject commit 7dc6de6d44575d238d82461d46def0b51d90af88 +Subproject commit 6f11733166454e1502a5832f8504826d7f411a8d -- cgit v1.2.3 From 277974975507d50e97fdba2be8d3daad8eeb678a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 17 Jun 2018 16:19:38 +1200 Subject: Update markdown_autoformat.vim --- vim/bundle/markdown_autoformat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/markdown_autoformat b/vim/bundle/markdown_autoformat index aedaec55..a1093557 160000 --- a/vim/bundle/markdown_autoformat +++ b/vim/bundle/markdown_autoformat @@ -1 +1 @@ -Subproject commit aedaec551e8f172a3a30cd893c8374d3e7e27008 +Subproject commit a109355774c8b1eccfa865156e557ee1734b3f00 -- cgit v1.2.3 From e17e9a23ff52dee7f921767b93d76597a8432f3c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 17 Jun 2018 21:54:54 +1200 Subject: Update auto_cache_dirs.vim --- vim/bundle/auto_cache_dirs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/auto_cache_dirs b/vim/bundle/auto_cache_dirs index b51aebde..fc1853e7 160000 --- a/vim/bundle/auto_cache_dirs +++ b/vim/bundle/auto_cache_dirs @@ -1 +1 @@ -Subproject commit b51aebde5bec9d58dba96377e0348fa82274bb83 +Subproject commit fc1853e7cdda432e9e91b1352038e3cfe591e9d7 -- cgit v1.2.3 From 8f34761e15a1c9cf90acd4cf9752443634478e75 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 17 Jun 2018 21:57:43 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 92021c1b..d59007a1 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v0.54.0 -Sat Jun 16 12:59:27 UTC 2018 +tejr dotfiles v0.55.0 +Sun Jun 17 09:57:37 UTC 2018 -- cgit v1.2.3