mirror of
https://github.com/dense-analysis/ale
synced 2024-12-30 10:02:14 +00:00
9fe7b1fe6a
Working directories are now set seperately from the commands so they can later be swapped out when running linters over projects is supported, and also better support filename mapping for running linters on other machines in future.
30 lines
1.2 KiB
VimL
30 lines
1.2 KiB
VimL
" 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
|
|
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}')
|
|
|
|
return '%e -q --language=c'
|
|
\ . l:template
|
|
\ . ale#Pad(l:compile_commands_option)
|
|
\ . ale#Pad(ale#Var(a:buffer, 'c_cppcheck_options'))
|
|
\ . l:buffer_path_include
|
|
\ . ' %t'
|
|
endfunction
|
|
|
|
call ale#linter#Define('c', {
|
|
\ 'name': 'cppcheck',
|
|
\ 'output_stream': 'both',
|
|
\ 'executable': {b -> ale#Var(b, 'c_cppcheck_executable')},
|
|
\ 'cwd': function('ale#handlers#cppcheck#GetCwd'),
|
|
\ 'command': function('ale_linters#c#cppcheck#GetCommand'),
|
|
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
|
|
\})
|