2018-03-31 10:55:20 -04:00
|
|
|
" Author: Bart Libert <bart.libert@gmail.com>
|
|
|
|
" Description: cppcheck linter for c files
|
|
|
|
|
|
|
|
call ale#Set('c_cppcheck_executable', 'cppcheck')
|
|
|
|
call ale#Set('c_cppcheck_options', '--enable=style')
|
|
|
|
|
|
|
|
function! ale_linters#c#cppcheck#GetCommand(buffer) abort
|
2019-07-08 12:44:45 -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)
|
2018-03-31 10:55:20 -04:00
|
|
|
\ : ''
|
|
|
|
|
|
|
|
return l:cd_command
|
2019-05-31 14:39:36 -04:00
|
|
|
\ . '%e -q --language=c'
|
|
|
|
\ . ale#Pad(l:compile_commands_option)
|
|
|
|
\ . ale#Pad(ale#Var(a:buffer, 'c_cppcheck_options'))
|
2019-07-08 12:44:45 -04:00
|
|
|
\ . l:buffer_path_include
|
2018-03-31 10:55:20 -04:00
|
|
|
\ . ' %t'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('c', {
|
|
|
|
\ 'name': 'cppcheck',
|
|
|
|
\ 'output_stream': 'both',
|
2019-03-08 06:04:56 -05:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'c_cppcheck_executable')},
|
|
|
|
\ 'command': function('ale_linters#c#cppcheck#GetCommand'),
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
|
|
|
|
\})
|