diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index af5de87d..7f836a29 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -362,13 +362,9 @@ endfunction "highlight the current errors using matchadd() " -"The function `Syntastic_{&ft}_GetHighlightRegex` is used to get the regex to -"highlight errors that do not have a 'col' key (and hence cant be done -"automatically). This function must take one arg (an error item) and return a -"regex to match that item in the buffer. -" -"If the 'force_highlight_callback' key is set for an error item, then invoke -"the callback even if it can be highlighted automatically. +"The function `Syntastic_{filetype}_{checker}_GetHighlightRegex` is used +"to override default highlighting. This function must take one arg (an +"error item) and return a regex to match that item in the buffer. function! s:HighlightErrors() call s:ClearErrorHighlights() let loclist = s:LocList() @@ -377,22 +373,17 @@ function! s:HighlightErrors() for ft in split(fts, '\.') for item in loclist.toRaw() - - let force_callback = has_key(item, 'force_highlight_callback') && item['force_highlight_callback'] - let group = item['type'] == 'E' ? 'SyntasticError' : 'SyntasticWarning' - if get( item, 'col' ) && !force_callback + + if exists('*SyntaxCheckers_'. ft . '_' . item['checker'] .'_GetHighlightRegex') + let term = SyntaxCheckers_{ft}_{item['checker']}_GetHighlightRegex(item) + if len(term) > 0 + call matchadd(group, '\%' . item['lnum'] . 'l' . term) + endif + elseif get(item, 'col') let lastcol = col([item['lnum'], '$']) let lcol = min([lastcol, item['col']]) call matchadd(group, '\%'.item['lnum'].'l\%'.lcol.'c') - else - - if exists("*SyntaxCheckers_". ft ."_GetHighlightRegex") - let term = SyntaxCheckers_{ft}_GetHighlightRegex(item) - if len(term) > 0 - call matchadd(group, '\%' . item['lnum'] . 'l' . term) - endif - endif endif endfor endfor @@ -606,12 +597,12 @@ function! SyntasticMake(options) endif if has_key(a:options, 'defaults') - call SyntasticAddToErrors(errors, a:options['defaults']) + call g:SyntasticAddToErrors(errors, a:options['defaults']) endif " Add subtype info if present. if has_key(a:options, 'subtype') - call SyntasticAddToErrors(errors, {'subtype': a:options['subtype']}) + call g:SyntasticAddToErrors(errors, {'subtype': a:options['subtype']}) endif return errors @@ -626,7 +617,7 @@ function! SyntasticErrorBalloonExpr() endfunction "take a list of errors and add default values to them from a:options -function! SyntasticAddToErrors(errors, options) +function! g:SyntasticAddToErrors(errors, options) for i in range(0, len(a:errors)-1) for key in keys(a:options) if !has_key(a:errors[i], key) || empty(a:errors[i][key]) diff --git a/plugin/syntastic/checker.vim b/plugin/syntastic/checker.vim index 12731e32..d8433b46 100644 --- a/plugin/syntastic/checker.vim +++ b/plugin/syntastic/checker.vim @@ -37,6 +37,7 @@ endfunction function! g:SyntasticChecker.getLocList() let list = self._locListFunc() + call g:SyntasticAddToErrors(list, {'checker': self._name}) return g:SyntasticLoclist.New(list) endfunction diff --git a/plugin/syntastic/loclist.vim b/plugin/syntastic/loclist.vim index 862a3f9a..d34e5cd2 100644 --- a/plugin/syntastic/loclist.vim +++ b/plugin/syntastic/loclist.vim @@ -90,3 +90,5 @@ function! g:SyntasticLoclist.filter(filters) endfor return rv endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/syntax_checkers/lua/luac.vim b/syntax_checkers/lua/luac.vim index b753edc0..464e14f7 100644 --- a/syntax_checkers/lua/luac.vim +++ b/syntax_checkers/lua/luac.vim @@ -19,7 +19,7 @@ function! SyntaxCheckers_lua_luac_IsAvailable() return executable('luac') endfunction -function! SyntaxCheckers_lua_GetHighlightRegex(pos) +function! SyntaxCheckers_lua_luac_GetHighlightRegex(pos) let near = matchstr(a:pos['text'], "near '[^']\\+'") let result = '' if len(near) > 0 diff --git a/syntax_checkers/php/php.vim b/syntax_checkers/php/php.vim index 32e0e671..8736daf1 100644 --- a/syntax_checkers/php/php.vim +++ b/syntax_checkers/php/php.vim @@ -19,7 +19,7 @@ function! SyntaxCheckers_php_php_IsAvailable() return executable("php") endfunction -function! SyntaxCheckers_php_GetHighlightRegex(item) +function! SyntaxCheckers_php_php_GetHighlightRegex(item) let unexpected = matchstr(a:item['text'], "unexpected '[^']\\+'") if len(unexpected) < 1 return '' diff --git a/syntax_checkers/twig/twiglint.vim b/syntax_checkers/twig/twiglint.vim index e1c89cbc..919ec48b 100644 --- a/syntax_checkers/twig/twiglint.vim +++ b/syntax_checkers/twig/twiglint.vim @@ -15,7 +15,7 @@ if exists("g:loaded_syntastic_twig_twiglint_checker") endif let g:loaded_syntastic_twig_twiglint_checker=1 -function! SyntaxCheckers_twig_GetHighlightRegex(item) +function! SyntaxCheckers_twig_twiglint_GetHighlightRegex(item) " Let's match the full line for now return '\V' endfunction diff --git a/syntax_checkers/vala/valac.vim b/syntax_checkers/vala/valac.vim index 73ac4261..e9b56012 100644 --- a/syntax_checkers/vala/valac.vim +++ b/syntax_checkers/vala/valac.vim @@ -55,8 +55,7 @@ function! SyntaxCheckers_vala_valac_GetLocList() let errorformat = '%A%f:%l.%c-%\d%\+.%\d%\+: %t%[a-z]%\+: %m,%C%m,%Z%m' return SyntasticMake({ 'makeprg': makeprg, - \ 'errorformat': errorformat, - \ 'defaults': {'force_highlight_callback': 1} }) + \ 'errorformat': errorformat }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({