cppcheck.vim (1628B)
1 " vim compiler file 2 " Compiler: cppcheck (C++ static checker) 3 " Maintainer: Vincent B. (twinside@free.fr) 4 " Last Change: 2025 Nov 06 by @Konfekt 5 6 if exists("current_compiler") | finish | endif 7 let current_compiler = "cppcheck" 8 9 let s:cpo_save = &cpo 10 set cpo&vim 11 12 let s:slash = has('win32')? '\' : '/' 13 14 if !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' 19 endif 20 21 exe 'CompilerSet makeprg=' .. escape('cppcheck --quiet' 22 \ ..' --template="{file}:{line}:{column}: {severity}: [{id}] {message} {callstack}"' 23 \ ..' '..get(b:, 'c_cppcheck_params', get(g:, 'c_cppcheck_params', (&filetype ==# 'cpp' ? ' --language=c++' : ''))) 24 \ ..' '..get(b:, 'c_cppcheck_includes', get(g:, 'c_cppcheck_includes', 25 \ (filereadable('compile_commands.json') ? '--project=compile_commands.json' : 26 \ (!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'))))), 28 \ ' \|"') 29 30 CompilerSet 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 37 exe get(s:, 'undo_compiler', '') 38 39 let &cpo = s:cpo_save 40 unlet s:cpo_save