From 33d7086c347f6a3750dcf7f03049ffcc0c7cd04f Mon Sep 17 00:00:00 2001 From: Tim Carey-Smith Date: Fri, 17 Jul 2009 11:51:48 +0800 Subject: [PATCH] Only auto-display the loclist if there are errors, but not if there are only warnings Signed-off-by: Martin Grenfell --- plugin/syntastic.vim | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index 7e7abc1b..a3e1d5c9 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -146,10 +146,21 @@ function! s:CacheErrors() endfunction "return true if there are cached errors for this buf -function! s:BufHasErrors() +function! s:BufHasErrorsOrWarnings() return exists("b:syntastic_loclist") && !empty(b:syntastic_loclist) endfunction +function! s:BufHasErrors() + if exists("b:syntastic_loclist") + for i in b:syntastic_loclist + if i['type'] == 'E' + return 1 + endif + endfor + endif + return 0 +endfunction + "use >> to display syntax errors in the sign column sign define SyntasticError text=>> texthl=error @@ -163,7 +174,7 @@ let s:next_sign_id = s:first_sign_id "place signs by all syntax errs in the buffer function s:SignErrors() - if s:BufHasErrors() + if s:BufHasErrorsOrWarnings() for i in b:syntastic_loclist let sign_type = 'SyntasticError' if i['type'] == 'W' @@ -217,7 +228,7 @@ command Errors call s:ShowLocList() " "return '' if no errors are cached for the buffer function! SyntasticStatuslineFlag() - if s:BufHasErrors() + if s:BufHasErrorsOrWarnings() let first_err_line = b:syntastic_loclist[0]['lnum'] let err_count = "" if len(b:syntastic_loclist) > 1