From 441506c06177125ddb714ed84240c3184804bab4 Mon Sep 17 00:00:00 2001 From: kongo2002 Date: Sun, 4 Mar 2012 21:08:04 +0100 Subject: [PATCH] cpp: add option to remove include errors --- syntax_checkers/cpp.vim | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/syntax_checkers/cpp.vim b/syntax_checkers/cpp.vim index 7166c44b..5fc6111e 100644 --- a/syntax_checkers/cpp.vim +++ b/syntax_checkers/cpp.vim @@ -45,6 +45,12 @@ " checking execution via the variable 'g:syntastic_cpp_compiler_options': " " let g:syntastic_cpp_compiler_options = ' -std=c++0x' +" +" Using the global variable 'g:syntastic_cpp_remove_include_errors' you can +" specify whether errors of files included via the +" g:syntastic_cpp_include_dirs' setting are removed from the result set: +" +" let g:syntastic_cpp_remove_include_errors = 1 if exists('loaded_cpp_syntax_checker') finish @@ -93,7 +99,18 @@ function! SyntaxCheckers_cpp_GetLocList() let makeprg .= b:syntastic_cpp_cflags endif - return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + " process makeprg + let errors = SyntasticMake({ 'makeprg': makeprg, + \ 'errorformat': errorformat }) + + " filter the processed errors if desired + if exists('g:syntastic_cpp_remove_include_errors') && + \ g:syntastic_cpp_remove_include_errors != 0 + return filter(errors, + \ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr('')) + else + return errors + endif endfunction let &cpo = s:save_cpo