X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/0ee596c5c5e11fc79598407eaf22f83d279f7e9e..5a4872f466ebd76ddd532bdf2798554421c53df4:/.vim/bundle/ale/ale_linters/cpp/clangcheck.vim?ds=inline diff --git a/.vim/bundle/ale/ale_linters/cpp/clangcheck.vim b/.vim/bundle/ale/ale_linters/cpp/clangcheck.vim new file mode 100644 index 00000000..4cb04864 --- /dev/null +++ b/.vim/bundle/ale/ale_linters/cpp/clangcheck.vim @@ -0,0 +1,35 @@ +" Author: gagbo +" Description: clang-check linter for cpp files + +call ale#Set('cpp_clangcheck_executable', 'clang-check') +call ale#Set('cpp_clangcheck_options', '') +call ale#Set('c_build_dir', '') + +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 + let l:build_dir = ale#Var(a:buffer, 'c_build_dir') + + if empty(l:build_dir) + let [l:root, l:json_file] = ale#c#FindCompileCommands(a:buffer) + let l:build_dir = ale#path#Dirname(l:json_file) + endif + + " The extra arguments in the command are used to prevent .plist files from + " being generated. These are only added if no build directory can be + " detected. + return '%e -analyze %s' + \ . (empty(l:build_dir) ? ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics': '') + \ . ale#Pad(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': {b -> ale#Var(b, 'cpp_clangcheck_executable')}, +\ 'command': function('ale_linters#cpp#clangcheck#GetCommand'), +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\ 'lint_file': 1, +\})