blob: 4df12d1714f64d2ecdbf529c663376f5c6eeb15d [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)
Konfekt0f60fbf2024-11-08 18:49:43 +01004" Last Change: 2024 Nov 08 by @Konfekt
Konfektaf449f62024-10-05 17:09:21 +02005
Enno3780c112024-11-06 20:14:49 +01006if exists("current_compiler") | finish | endif
Konfektaf449f62024-10-05 17:09:21 +02007let current_compiler = "cppcheck"
8
9let s:cpo_save = &cpo
Enno3780c112024-11-06 20:14:49 +010010set cpo&vim
Konfektaf449f62024-10-05 17:09:21 +020011
Konfekt5e48e972024-10-17 20:54:00 +020012let s:slash = has('win32')? '\' : '/'
13
Konfektaf449f62024-10-05 17:09:21 +020014if !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}"'
Konfekt5e48e972024-10-17 20:54:00 +020023 \ ..' '..get(b:, 'c_cppcheck_params', get(g:, 'c_cppcheck_params', (&filetype ==# 'cpp' ? ' --language=c++' : '')))
Konfektaf449f62024-10-05 17:09:21 +020024 \ ..' '..get(b:, 'c_cppcheck_includes', get(g:, 'c_cppcheck_includes',
25 \ (filereadable('compile_commands.json') ? '--project=compile_commands.json' :
Konfekt5e48e972024-10-17 20:54:00 +020026 \ (!empty(glob('*'..s:slash..'compile_commands.json', 1, 1)) ? '--project='..glob('*'..s:slash..'compile_commands.json', 1, 1)[0] :
27 \ (empty(&path) ? '' : '-I')..join(map(filter(split(&path, ','), 'isdirectory(v:val)'),'shellescape(v:val)'), ' -I')))))
Konfekt0f60fbf2024-11-08 18:49:43 +010028exe 'CompilerSet makeprg='..escape(&l:makeprg, ' "')
Konfektaf449f62024-10-05 17:09:21 +020029
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