diff options
Diffstat (limited to 'vim/after')
-rw-r--r-- | vim/after/ftplugin/html/lint.vim | 16 | ||||
-rw-r--r-- | vim/after/ftplugin/perl/check.vim | 16 | ||||
-rw-r--r-- | vim/after/ftplugin/perl/lint.vim | 16 | ||||
-rw-r--r-- | vim/after/ftplugin/sh/check.vim | 26 | ||||
-rw-r--r-- | vim/after/ftplugin/sh/lint.vim | 26 | ||||
-rw-r--r-- | vim/after/ftplugin/vim/lint.vim | 16 | ||||
-rw-r--r-- | vim/after/syntax/sh.vim | 17 |
7 files changed, 118 insertions, 15 deletions
diff --git a/vim/after/ftplugin/html/lint.vim b/vim/after/ftplugin/html/lint.vim index 3ac760ed..c0fdc44f 100644 --- a/vim/after/ftplugin/html/lint.vim +++ b/vim/after/ftplugin/html/lint.vim @@ -11,13 +11,27 @@ if exists('b:undo_ftplugin') \ . '|unlet b:did_ftplugin_html_lint' endif +" Build function for linter +if !exists('*s:HtmlLint') + function s:HtmlLint() + let l:save_makeprg = &l:makeprg + let l:save_errorformat = &l:errorformat + unlet! g:current_compiler + compiler tidy + make! + let &l:makeprg = l:save_makeprg + let &l:errorformat = l:save_errorformat + cwindow + endfunction +endif + " Set up a mapping for the linter, if we're allowed if !exists('g:no_plugin_maps') && !exists('g:no_html_maps') " Define a mapping target nnoremap <buffer> <silent> <unique> \ <Plug>HtmlLint - \ :<C-U>write !tidy -errors -quiet<CR> + \ :<C-U>call <SID>HtmlLint()<CR> if exists('b:undo_ftplugin') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap <buffer> <Plug>HtmlLint' diff --git a/vim/after/ftplugin/perl/check.vim b/vim/after/ftplugin/perl/check.vim index 6b057c82..df90784f 100644 --- a/vim/after/ftplugin/perl/check.vim +++ b/vim/after/ftplugin/perl/check.vim @@ -9,13 +9,27 @@ if exists('b:undo_ftplugin') \ . '|unlet b:did_ftplugin_perl_check' endif +" Build function for checker +if !exists('*s:PerlCheck') + function s:PerlCheck() + let l:save_makeprg = &l:makeprg + let l:save_errorformat = &l:errorformat + unlet! g:current_compiler + compiler perl + make! + let &l:makeprg = l:save_makeprg + let &l:errorformat = l:save_errorformat + cwindow + endfunction +endif + " Set up a mapping for the checker, if we're allowed if !exists('g:no_plugin_maps') && !exists('g:no_perl_maps') " Define a mapping target nnoremap <buffer> <silent> <unique> \ <Plug>PerlCheck - \ :<C-U>write !perl -c<CR> + \ :<C-U>call <SID>PerlCheck()<CR> if exists('b:undo_ftplugin') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap <buffer> <Plug>PerlCheck' diff --git a/vim/after/ftplugin/perl/lint.vim b/vim/after/ftplugin/perl/lint.vim index 86740c81..48b23091 100644 --- a/vim/after/ftplugin/perl/lint.vim +++ b/vim/after/ftplugin/perl/lint.vim @@ -9,13 +9,27 @@ if exists('b:undo_ftplugin') \ . '|unlet b:did_ftplugin_perl_lint' endif +" Build function for linter +if !exists('*s:PerlLint') + function s:PerlLint() + let l:save_makeprg = &l:makeprg + let l:save_errorformat = &l:errorformat + unlet! g:current_compiler + compiler perlcritic + make! + let &l:makeprg = l:save_makeprg + let &l:errorformat = l:save_errorformat + cwindow + endfunction +endif + " Set up a mapping for the linter, if we're allowed if !exists('g:no_plugin_maps') && !exists('g:no_perl_maps') " Define a mapping target nnoremap <buffer> <silent> <unique> \ <Plug>PerlLint - \ :<C-U>write !perlcritic<CR> + \ :<C-U>call <SID>PerlLint()<CR> if exists('b:undo_ftplugin') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap <buffer> <Plug>PerlLint' diff --git a/vim/after/ftplugin/sh/check.vim b/vim/after/ftplugin/sh/check.vim index 334ec1db..3eaf3f57 100644 --- a/vim/after/ftplugin/sh/check.vim +++ b/vim/after/ftplugin/sh/check.vim @@ -11,15 +11,31 @@ endif " Choose checker based on shell family if exists('b:is_bash') - let b:sh_check = 'write !bash -n' + let b:sh_check_makeprg = 'bash -n %:S' elseif exists('b:is_kornshell') - let b:sh_check = 'write !ksh -n' + let b:sh_check_makeprg = 'ksh -n %:S' else - let b:sh_check = 'write !sh -n' + let b:sh_check_makeprg = 'sh -n %:S' endif +let b:sh_check_errorformat = '%f: %l: %m' if exists('b:undo_ftplugin') let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:sh_check' + \ . '|unlet b:sh_check_makeprg' + \ . '|unlet b:sh_check_errorformat' +endif + +" Build function for checker +if !exists('*s:ShCheck') + function s:ShCheck() + let l:save_makeprg = &l:makeprg + let l:save_errorformat = &l:errorformat + let &l:makeprg = b:sh_check_makeprg + let &l:errorformat = b:sh_check_errorformat + make! + let &l:makeprg = l:save_makeprg + let &l:errorformat = l:save_errorformat + cwindow + endfunction endif " Set up a mapping for the checker, if we're allowed @@ -28,7 +44,7 @@ if !exists('g:no_plugin_maps') && !exists('g:no_sh_maps') " Define a mapping target nnoremap <buffer> <silent> <unique> \ <Plug>ShCheck - \ :<C-U>execute b:sh_check<CR> + \ :<C-U>call <SID>ShCheck()<CR> if exists('b:undo_ftplugin') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap <buffer> <Plug>ShCheck' diff --git a/vim/after/ftplugin/sh/lint.vim b/vim/after/ftplugin/sh/lint.vim index 8745a31e..7d6e4d75 100644 --- a/vim/after/ftplugin/sh/lint.vim +++ b/vim/after/ftplugin/sh/lint.vim @@ -11,15 +11,31 @@ endif " Choose linter based on shell family if exists('b:is_bash') - let b:sh_lint = 'write !shellcheck -e SC1090 -s bash -' + let b:sh_lint_makeprg = 'shellcheck -e SC1090 -f gcc -s bash %:S' elseif exists('b:is_kornshell') - let b:sh_lint = 'write !shellcheck -e SC1090 -s ksh -' + let b:sh_lint_makeprg = 'shellcheck -e SC1090 -f gcc -s ksh %:S' else - let b:sh_lint = 'write !shellcheck -e SC1090 -s sh -' + let b:sh_lint_makeprg = 'shellcheck -e SC1090 -f gcc -s sh %:S' endif +let b:sh_lint_errorformat = '%f:%l:%c: %m [SC%n]' if exists('b:undo_ftplugin') let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:sh_lint' + \ . '|unlet b:sh_lint_makeprg' + \ . '|unlet b:sh_lint_errorformat' +endif + +" Build function for checker +if !exists('*s:ShLint') + function s:ShLint() + let l:save_makeprg = &l:makeprg + let l:save_errorformat = &l:errorformat + let &l:makeprg = b:sh_lint_makeprg + let &l:errorformat = b:sh_lint_errorformat + make! + let &l:makeprg = l:save_makeprg + let &l:errorformat = l:save_errorformat + cwindow + endfunction endif " Set up a mapping for the linter, if we're allowed @@ -28,7 +44,7 @@ if !exists('g:no_plugin_maps') && !exists('g:no_sh_maps') " Define a mapping target nnoremap <buffer> <silent> <unique> \ <Plug>ShLint - \ :<C-U>execute b:sh_lint<CR> + \ :<C-U>call <SID>ShLint()<CR> if exists('b:undo_ftplugin') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap <buffer> <Plug>ShLint' diff --git a/vim/after/ftplugin/vim/lint.vim b/vim/after/ftplugin/vim/lint.vim index 1b557593..2c402964 100644 --- a/vim/after/ftplugin/vim/lint.vim +++ b/vim/after/ftplugin/vim/lint.vim @@ -9,13 +9,27 @@ if exists('b:undo_ftplugin') \ . '|unlet b:did_ftplugin_vim_lint' endif +" Build function for checker +if !exists('*s:VimLint') + function s:VimLint() + let l:save_makeprg = &l:makeprg + let l:save_errorformat = &l:errorformat + unlet! g:current_compiler + compiler vint + make! + let &l:makeprg = l:save_makeprg + let &l:errorformat = l:save_errorformat + cwindow + endfunction +endif + " Set up a mapping for the linter, if we're allowed if !exists('g:no_plugin_maps') && !exists('g:no_vim_maps') " Define a mapping target nnoremap <buffer> <silent> <unique> \ <Plug>VimLint - \ :<C-U>write !vint -s /dev/stdin<CR> + \ :<C-U>call <SID>VimLint()<CR> if exists('b:undo_ftplugin') let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap <buffer> <Plug>VimLint' diff --git a/vim/after/syntax/sh.vim b/vim/after/syntax/sh.vim index 8025c567..08dbd857 100644 --- a/vim/after/syntax/sh.vim +++ b/vim/after/syntax/sh.vim @@ -111,7 +111,7 @@ if exists('b:is_posix') syntax clear shRepeat syntax region shRepeat \ matchgroup=shLoop - \ start="\<while\_s" end="\<do\>"me=e-2 + \ start='\<while\_s' end='\<do\>'me=e-2 \ contains=@shLoopList " Run some clustering that core syntax/sh.vim thinks doesn't apply to POSIX; @@ -119,6 +119,21 @@ if exists('b:is_posix') syntax cluster shCaseList add=shRepeat syntax cluster shFunctionList add=shRepeat + " ${foo%bar}, ${foo%%bar}, ${foo#bar}, and ${foo##bar} are all valid forms + " of parameter expansion in POSIX, but sh.vim makes them conditional on + " Bash or Korn shell. We reinstate them (slightly adapted) here. + syntax match shDerefOp contained + \ '##\|#\|%%\|%' + \ nextgroup=@shDerefPatternList + syntax match shDerefPattern contained + \ '[^{}]\+' + \ contains=shDeref,shDerefSimple,shDerefPattern,shDerefString,shCommandSub,shDerefEscape + \ nextgroup=shDerefPattern + syntax region shDerefPattern contained + \ start='{' end='}' + \ contains=shDeref,shDerefSimple,shDerefString,shCommandSub + \ nextgroup=shDerefPattern + endif " Some corrections for highlighting specific to the Bash mode |