scrooloose/syntastic — Issue #124: Warnings should not mask Errors
Author: ashikase
Created: 2011-12-15 10:12:38+00:00
State: open

I am using syntastic with 'signs' enabled, and differentiate warnings and errors by sign color (traditional yellow and red).

When a syntax check finds multiple warnings and errors for a single line, a sign is only displayed for the last item. I've found that if the check finds an error, and then a warning, a sign is displayed for the warning instead of for, in my opinion, the more important error.

I have created a simplistic workaround for this issue, which I've pasted below. In essence, when processing signs, if an error is found, no further signs are processed. Note that I have little experience with vimscript; this may be/is a poor solution, though it does seem to solve the issue.

(The below code is based on git commit: d14b53e903...)

function s:SignErrors()
if s:BufHasErrorsOrWarningsToDisplay()
let lnum = 0
let hasError = 0
for i in b:syntastic_loclist
if i['bufnr'] != bufnr("")
continue
endif

if i['lnum'] == lnum
if hasError
continue
endif
else
let lnum = i['lnum']
let hasError = 0
endif

let sign_type = 'SyntasticError'
if i['type'] == 'W'
let sign_type = 'SyntasticWarning'
else
let hasError = 1
endif

exec "sign place ". s:next_sign_id ." line=". i['lnum'] ." name=". sign_type ." file=". expand("%:p")
call add(s:BufSignIds(), s:next_sign_id)
let s:next_sign_id += 1
endfor
endif
endfunction