2017-06-24 15:10:04 +00:00
|
|
|
" Author: gagbo <gagbobada@gmail.com>
|
|
|
|
" Description: clang-check linter for cpp files
|
|
|
|
|
2017-07-16 22:35:10 +00:00
|
|
|
call ale#Set('cpp_clangcheck_executable', 'clang-check')
|
|
|
|
call ale#Set('cpp_clangcheck_options', '')
|
|
|
|
call ale#Set('c_build_dir', '')
|
2017-06-24 15:10:04 +00:00
|
|
|
|
2017-07-16 22:35:10 +00:00
|
|
|
function! ale_linters#cpp#clangcheck#GetExecutable(buffer) abort
|
|
|
|
return ale#Var(a:buffer, 'cpp_clangcheck_executable')
|
|
|
|
endfunction
|
2017-06-24 15:10:04 +00:00
|
|
|
|
|
|
|
function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
|
|
|
|
let l:user_options = ale#Var(a:buffer, 'cpp_clangcheck_options')
|
|
|
|
|
|
|
|
" Try to find compilation database to link automatically
|
2017-07-16 22:35:10 +00:00
|
|
|
let l:build_dir = ale#Var(a:buffer, 'c_build_dir')
|
|
|
|
|
|
|
|
if empty(l:build_dir)
|
|
|
|
let l:build_dir = ale#c#FindCompileCommands(a:buffer)
|
2017-06-24 15:10:04 +00:00
|
|
|
endif
|
|
|
|
|
2017-07-16 22:35:10 +00:00
|
|
|
return ale#Escape(ale_linters#cpp#clangcheck#GetExecutable(a:buffer))
|
|
|
|
\ . ' -analyze %s'
|
|
|
|
\ . (!empty(l:user_options) ? ' ' . l:user_options : '')
|
|
|
|
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
|
2017-06-24 15:10:04 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('cpp', {
|
|
|
|
\ 'name': 'clangcheck',
|
|
|
|
\ 'output_stream': 'stderr',
|
2017-07-16 22:35:10 +00:00
|
|
|
\ 'executable_callback': 'ale_linters#cpp#clangcheck#GetExecutable',
|
2017-06-24 15:10:04 +00:00
|
|
|
\ 'command_callback': 'ale_linters#cpp#clangcheck#GetCommand',
|
|
|
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
|
|
|
\ 'lint_file': 1,
|
|
|
|
\})
|