blob: 20c906f4129e70efaec5f6dea4d5851597fc7128 [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)
Konfekt5e48e972024-10-17 20:54:00 +02004" Last Change: 2024 oct 17 by @Konfekt
Konfektaf449f62024-10-05 17:09:21 +02005
6if exists("cppcheck")
7 finish
8endif
9let current_compiler = "cppcheck"
10
11let s:cpo_save = &cpo
12set cpo-=C
13
Konfekt5e48e972024-10-17 20:54:00 +020014let s:slash = has('win32')? '\' : '/'
15
Konfektaf449f62024-10-05 17:09:21 +020016if !exists('g:c_cppcheck_params')
17 let g:c_cppcheck_params = '--verbose --force --inline-suppr'
18 \ ..' '..'--enable=warning,style,performance,portability,information,missingInclude'
19 \ ..' '..(executable('getconf') ? '-j' .. systemlist('getconf _NPROCESSORS_ONLN')[0] : '')
20 let s:undo_compiler = 'unlet! g:c_cppcheck_params'
21endif
22
23let &l:makeprg = 'cppcheck --quiet'
24 \ ..' --template="{file}:{line}:{column}: {severity}: [{id}] {message} {callstack}"'
Konfekt5e48e972024-10-17 20:54:00 +020025 \ ..' '..get(b:, 'c_cppcheck_params', get(g:, 'c_cppcheck_params', (&filetype ==# 'cpp' ? ' --language=c++' : '')))
Konfektaf449f62024-10-05 17:09:21 +020026 \ ..' '..get(b:, 'c_cppcheck_includes', get(g:, 'c_cppcheck_includes',
27 \ (filereadable('compile_commands.json') ? '--project=compile_commands.json' :
Konfekt5e48e972024-10-17 20:54:00 +020028 \ (!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')))))
Konfektaf449f62024-10-05 17:09:21 +020030silent CompilerSet makeprg
31
32CompilerSet errorformat=
33 \%f:%l:%c:\ %tarning:\ %m,
34 \%f:%l:%c:\ %trror:\ %m,
35 \%f:%l:%c:\ %tnformation:\ %m,
36 \%f:%l:%c:\ %m,
37 \%.%#\ :\ [%f:%l]\ %m
38
39exe get(s:, 'undo_compiler', '')
40
41let &cpo = s:cpo_save
42unlet s:cpo_save