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.
1 " Author: vdeurzen <tim@kompiler.org>, w0rp <devw0rp@gmail.com>,
2 " gagbo <gagbobada@gmail.com>, Andrej Radovic <r.andrej@gmail.com>
3 " Description: clang-tidy linter for c files
5 call ale#Set('c_clangtidy_executable', 'clang-tidy')
6 " Set this option to check the checks clang-tidy will apply.
7 " The number of checks that can be applied to C files is limited in contrast to
10 " Consult the check list in clang-tidy's documentation:
11 " http://clang.llvm.org/extra/clang-tidy/checks/list.html
13 call ale#Set('c_clangtidy_checks', [])
14 " Set this option to manually set some options for clang-tidy to use as compile
16 " This will disable compile_commands.json detection.
17 call ale#Set('c_clangtidy_options', '')
18 " Set this option to manually set options for clang-tidy directly.
19 call ale#Set('c_clangtidy_extra_options', '')
20 call ale#Set('c_build_dir', '')
22 function! ale_linters#c#clangtidy#GetCommand(buffer, output) abort
23 let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',')
24 let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
27 " Get the extra options if we couldn't find a build directory.
29 let l:options = ale#Var(a:buffer, 'c_clangtidy_options')
30 let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
31 let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags
34 " Get the options to pass directly to clang-tidy
35 let l:extra_options = ale#Var(a:buffer, 'c_clangtidy_extra_options')
38 \ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
39 \ . (!empty(l:extra_options) ? ' ' . ale#Escape(l:extra_options) : '')
41 \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
42 \ . (!empty(l:options) ? ' -- ' . l:options : '')
45 call ale#linter#Define('c', {
46 \ 'name': 'clangtidy',
47 \ 'output_stream': 'stdout',
48 \ 'executable': {b -> ale#Var(b, 'c_clangtidy_executable')},
49 \ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#clangtidy#GetCommand'))},
50 \ 'callback': 'ale#handlers#gcc#HandleGCCFormat',