blob: ed7c46e90f90170081822e516babf98c85f60b40 [file] [log] [blame]
Konfektaf449f62024-10-05 17:09:21 +02001" vim compiler file
2" Compiler: cppcheck (C++ static checker)
3" Maintainer: Vincent B. (twinside@free.fr)
4" Last Change: 2024 Oct 4 by @Konfekt
5
6if exists("cppcheck")
7 finish
8endif
9let current_compiler = "cppcheck"
10
11let s:cpo_save = &cpo
12set cpo-=C
13
14if !exists('g:c_cppcheck_params')
15 let g:c_cppcheck_params = '--verbose --force --inline-suppr'
16 \ ..' '..'--enable=warning,style,performance,portability,information,missingInclude'
17 \ ..' '..(executable('getconf') ? '-j' .. systemlist('getconf _NPROCESSORS_ONLN')[0] : '')
18 let s:undo_compiler = 'unlet! g:c_cppcheck_params'
19endif
20
21let &l:makeprg = 'cppcheck --quiet'
22 \ ..' --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_includes', get(g:, 'c_cppcheck_includes',
26 \ (filereadable('compile_commands.json') ? '--project=compile_commands.json' :
27 \ (empty(&path) ? '' : '-I')..join(map(filter(split(&path, ','), 'isdirectory(v:val)'),'shellescape(v:val)'), ' -I'))))
28silent CompilerSet makeprg
29
30CompilerSet errorformat=
31 \%f:%l:%c:\ %tarning:\ %m,
32 \%f:%l:%c:\ %trror:\ %m,
33 \%f:%l:%c:\ %tnformation:\ %m,
34 \%f:%l:%c:\ %m,
35 \%.%#\ :\ [%f:%l]\ %m
36
37exe get(s:, 'undo_compiler', '')
38
39let &cpo = s:cpo_save
40unlet s:cpo_save