summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/cpp/clangcheck.vim32
1 files changed, 15 insertions, 17 deletions
diff --git a/ale_linters/cpp/clangcheck.vim b/ale_linters/cpp/clangcheck.vim
index 11184cb8..936204d8 100644
--- a/ale_linters/cpp/clangcheck.vim
+++ b/ale_linters/cpp/clangcheck.vim
@@ -1,36 +1,34 @@
" Author: gagbo <gagbobada@gmail.com>
" Description: clang-check linter for cpp files
-" Set this option to manually set some options for clang-check.
-let g:ale_cpp_clangcheck_options = get(g:, 'ale_cpp_clangcheck_options', '')
+call ale#Set('cpp_clangcheck_executable', 'clang-check')
+call ale#Set('cpp_clangcheck_options', '')
+call ale#Set('c_build_dir', '')
-" Set this option to manually point to the build directory for clang-tidy.
-" This will disable all the other clangtidy_options, since compilation
-" flags are contained in the json
-let g:ale_c_build_dir = get(g:, 'ale_c_build_dir', '')
+function! ale_linters#cpp#clangcheck#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'cpp_clangcheck_executable')
+endfunction
function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
let l:user_options = ale#Var(a:buffer, 'cpp_clangcheck_options')
- let l:extra_options = !empty(l:user_options)
- \ ? l:user_options
- \ : ''
" Try to find compilation database to link automatically
- let l:user_build_dir = ale#Var(a:buffer, 'c_build_dir')
- if empty(l:user_build_dir)
- let l:user_build_dir = ale#c#FindCompileCommands(a:buffer)
+ 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)
endif
- let l:build_options = !empty(l:user_build_dir)
- \ ? ' -p ' . ale#Escape(l:user_build_dir)
- \ : ''
- return 'clang-check -analyze ' . '%s' . l:extra_options . l:build_options
+ 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) : '')
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'clangcheck',
\ 'output_stream': 'stderr',
-\ 'executable': 'clang-check',
+\ 'executable_callback': 'ale_linters#cpp#clangcheck#GetExecutable',
\ 'command_callback': 'ale_linters#cpp#clangcheck#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1,