remove custom highlights manually - not with matchclear()

Previously we were blowing away highlights that were added by other
plugins via matchadd(). To prevent this we now track all the ids of the
highlights groups we add and remove them explicitly with matchdelete().
This commit is contained in:
Martin Grenfell 2011-11-27 15:35:56 +00:00
parent 3c26740b28
commit f428139a0f

View File

@ -12,23 +12,42 @@ function! syntastic#ErrorBalloonExpr()
endfunction
function! syntastic#HighlightErrors(errors, termfunc, ...)
call clearmatches()
call syntastic#ClearErrorHighlights()
let forcecb = a:0 && a:1
for item in a:errors
let group = item['type'] == 'E' ? 'SpellBad' : 'SpellCap'
if item['col'] && !forcecb
let lastcol = col([item['lnum'], '$'])
let lcol = min([lastcol, item['col']])
call matchadd(group, '\%'.item['lnum'].'l\%'.lcol.'c')
call syntastic#HighlightError(group, '\%'.item['lnum'].'l\%'.lcol.'c')
else
let term = a:termfunc(item)
if len(term) > 0
call matchadd(group, '\%' . item['lnum'] . 'l' . term)
call syntastic#HighlightError(group, '\%' . item['lnum'] . 'l' . term)
endif
endif
endfor
endfunction
function! syntastic#ClearErrorHighlights()
for i in syntastic#ErrorHighlightIds()
call matchdelete(i)
endfor
let b:syntastic_error_highlight_ids = []
endfunction
function! syntastic#HighlightError(group, pattern)
call add(syntastic#ErrorHighlightIds(), matchadd(a:group, a:pattern))
endfunction
function! syntastic#ErrorHighlightIds()
if !exists("b:syntastic_error_highlight_ids")
let b:syntastic_error_highlight_ids = []
endif
return b:syntastic_error_highlight_ids
endfunction
" initialize c/cpp syntax checker handlers
function! s:Init()
let s:handlers = []