Fix syntax highlighting.
The variable force_highlight_callback is gone. Highlight functions are now consistently named SyntaxCheckers_<filetype>_<checker>_GetHighlightRegex(), and they take precedence over highlighting based on column.
This commit is contained in:
parent
ed300e34e7
commit
ff3c05a413
@ -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])
|
||||
|
@ -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
|
||||
|
||||
|
@ -90,3 +90,5 @@ function! g:SyntasticLoclist.filter(filters)
|
||||
endfor
|
||||
return rv
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
@ -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
|
||||
|
@ -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 ''
|
||||
|
@ -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
|
||||
|
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user