]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/c/clangcheck.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / ale_linters / c / clangcheck.vim
1 " Author: gagbo <gagbobada@gmail.com>
2 "       : luibo <ng.akhoa98@gmail.com>
3 "       : Jorengarenar <jorengarenar@outlook.com>
4 " Description: clang-check linter for C files
5 "              modified from cpp/clangcheck.vim to match for C
6
7 call ale#Set('c_clangcheck_executable', 'clang-check')
8 call ale#Set('c_clangcheck_options', '')
9 call ale#Set('c_build_dir', '')
10
11 function! ale_linters#c#clangcheck#GetCommand(buffer) abort
12     let l:user_options = ale#Var(a:buffer, 'c_clangcheck_options')
13
14     " Try to find compilation database to link automatically
15     let l:build_dir = ale#Var(a:buffer, 'c_build_dir')
16
17     if empty(l:build_dir)
18         let [l:root, l:json_file] = ale#c#FindCompileCommands(a:buffer)
19         let l:build_dir = ale#path#Dirname(l:json_file)
20     endif
21
22     " The extra arguments in the command are used to prevent .plist files from
23     " being generated. These are only added if no build directory can be
24     " detected.
25     return '%e -analyze %s'
26     \   . (empty(l:build_dir) ? ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics': '')
27     \   . ale#Pad(l:user_options)
28     \   . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
29 endfunction
30
31 call ale#linter#Define('c', {
32 \   'name': 'clangcheck',
33 \   'output_stream': 'stderr',
34 \   'executable': {b -> ale#Var(b, 'c_clangcheck_executable')},
35 \   'command': function('ale_linters#c#clangcheck#GetCommand'),
36 \   'callback': 'ale#handlers#gcc#HandleGCCFormat',
37 \   'lint_file': 1,
38 \})