mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-22 20:11:26 +08:00
35 lines
1.4 KiB
VimL
35 lines
1.4 KiB
VimL
" Author: Bart Libert <bart.libert@gmail.com>
|
|
" Description: cppcheck linter for cpp files
|
|
|
|
call ale#Set('cpp_cppcheck_executable', 'cppcheck')
|
|
call ale#Set('cpp_cppcheck_options', '--enable=style')
|
|
|
|
function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
|
|
let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer)
|
|
let l:buffer_path_include = empty(l:compile_commands_option)
|
|
\ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer)
|
|
\ : ''
|
|
let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
|
|
" Versions >=2.13 don't allow using --project in conjunction with an
|
|
" explicit source file.
|
|
let l:source_file = stridx(l:compile_commands_option, '--project=') < 0
|
|
\ ? ' %t'
|
|
\ : ''
|
|
|
|
return '%e -q --language=c++'
|
|
\ . l:template
|
|
\ . ale#Pad(l:compile_commands_option)
|
|
\ . ale#Pad(ale#Var(a:buffer, 'cpp_cppcheck_options'))
|
|
\ . l:buffer_path_include
|
|
\ . l:source_file
|
|
endfunction
|
|
|
|
call ale#linter#Define('cpp', {
|
|
\ 'name': 'cppcheck',
|
|
\ 'output_stream': 'both',
|
|
\ 'executable': {b -> ale#Var(b, 'cpp_cppcheck_executable')},
|
|
\ 'cwd': function('ale#handlers#cppcheck#GetCwd'),
|
|
\ 'command': function('ale_linters#cpp#cppcheck#GetCommand'),
|
|
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
|
|
\})
|