diff options
author | Gagbo <Gagbo@users.noreply.github.com> | 2017-06-24 17:10:04 +0200 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2017-06-24 16:10:04 +0100 |
commit | dc647fcc7fc716c3f5488fc7af115e64243e2021 (patch) | |
tree | d21953ba229b05fe2bef68d75b936a1af7742732 /ale_linters | |
parent | e98560a349f3381c8fc6ecb6bf149c337dcf17be (diff) | |
download | ale-dc647fcc7fc716c3f5488fc7af115e64243e2021.zip |
Add clangcheck Linter to cpp (#686)
Add a clangcheck linter
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/cpp/clangcheck.vim | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ale_linters/cpp/clangcheck.vim b/ale_linters/cpp/clangcheck.vim new file mode 100644 index 00000000..11184cb8 --- /dev/null +++ b/ale_linters/cpp/clangcheck.vim @@ -0,0 +1,37 @@ +" 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', '') + +" 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#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) + 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 +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'clangcheck', +\ 'output_stream': 'stderr', +\ 'executable': 'clang-check', +\ 'command_callback': 'ale_linters#cpp#clangcheck#GetCommand', +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\ 'lint_file': 1, +\}) |