2016-10-20 07:30:45 -04:00
|
|
|
" Author: Bart Libert <bart.libert@gmail.com>
|
|
|
|
" Description: cppcheck linter for cpp files
|
|
|
|
|
2017-07-16 17:11:43 -04:00
|
|
|
call ale#Set('cpp_cppcheck_executable', 'cppcheck')
|
|
|
|
call ale#Set('cpp_cppcheck_options', '--enable=style')
|
|
|
|
|
2017-04-15 20:24:08 -04:00
|
|
|
function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
|
2019-06-03 16:49:51 -04:00
|
|
|
let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer)
|
|
|
|
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)
|
2017-05-02 16:18:17 -04:00
|
|
|
\ : ''
|
|
|
|
|
|
|
|
return l:cd_command
|
2019-05-20 17:08:03 -04:00
|
|
|
\ . '%e -q --language=c++'
|
|
|
|
\ . ale#Pad(l:compile_commands_option)
|
|
|
|
\ . ale#Pad(ale#Var(a:buffer, 'cpp_cppcheck_options'))
|
2019-06-03 16:49:51 -04:00
|
|
|
\ . l:buffer_path_include
|
2017-04-15 20:24:08 -04:00
|
|
|
\ . ' %t'
|
|
|
|
endfunction
|
|
|
|
|
2016-10-20 07:30:45 -04:00
|
|
|
call ale#linter#Define('cpp', {
|
|
|
|
\ 'name': 'cppcheck',
|
|
|
|
\ 'output_stream': 'both',
|
2019-02-22 13:05:04 -05:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'cpp_cppcheck_executable')},
|
|
|
|
\ 'command': function('ale_linters#cpp#cppcheck#GetCommand'),
|
2017-04-24 17:27:18 -04:00
|
|
|
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
|
2016-10-20 07:30:45 -04:00
|
|
|
\})
|