11" vim compiler file
22" Compiler: cppcheck (C++ static checker)
33" Maintainer: Vincent B. (twinside@free.fr)
4- " Last Change: 2024 Oct 4 by @Konfekt
4+ " Last Change: 2024 oct 17 by @Konfekt
55
66if exists (" cppcheck" )
77 finish
@@ -11,6 +11,8 @@ let current_compiler = "cppcheck"
1111let s: cpo_save = &cpo
1212set cpo -= C
1313
14+ let s: slash = has (' win32' )? ' \' : ' /'
15+
1416if ! exists (' g:c_cppcheck_params' )
1517 let g: c_cppcheck_params = ' --verbose --force --inline-suppr'
1618 \ ..' ' ..' --enable=warning,style,performance,portability,information,missingInclude'
@@ -20,11 +22,11 @@ endif
2022
2123let &l: makeprg = ' cppcheck --quiet'
2224 \ ..' --template="{file}:{line}:{column}: {severity}: [{id}] {message} {callstack}"'
23- \ ..' ' ..get (b: , ' c_cppcheck_params' ,
24- \ g: c_cppcheck_params ..' ' ..(&filetype == # ' cpp' ? ' --language=c++' : ' ' ))
25+ \ ..' ' ..get (b: , ' c_cppcheck_params' , get (g: , ' c_cppcheck_params' , (&filetype == # ' cpp' ? ' --language=c++' : ' ' )))
2526 \ ..' ' ..get (b: , ' c_cppcheck_includes' , get (g: , ' c_cppcheck_includes' ,
2627 \ (filereadable (' compile_commands.json' ) ? ' --project=compile_commands.json' :
27- \ (empty (&path ) ? ' ' : ' -I' )..join (map (filter (split (&path , ' ,' ), ' isdirectory(v:val)' ),' shellescape(v:val)' ), ' -I' ))))
28+ \ (! empty (glob (' *' ..s: slash ..' compile_commands.json' , 1 , 1 )) ? ' --project=' ..glob (' *' ..s: slash ..' compile_commands.json' , 1 , 1 )[0 ] :
29+ \ (empty (&path ) ? ' ' : ' -I' )..join (map (filter (split (&path , ' ,' ), ' isdirectory(v:val)' ),' shellescape(v:val)' ), ' -I' )))))
2830silent CompilerSet makeprg
2931
3032CompilerSet errorformat =
0 commit comments