diff options
author | Greg Anders <greg@gpanders.com> | 2019-10-06 10:29:17 -0600 |
---|---|---|
committer | Greg Anders <greg@gpanders.com> | 2019-10-06 10:29:17 -0600 |
commit | 06a97a854191b331b6ec37ef7ea0c59f671b1101 (patch) | |
tree | 0580cf5283d89504a40e4f97f9f2c83142ea97f5 /ale_linters/cpp | |
parent | a486aa1d24294c5b14c8b2763a3b5ffdc39d0739 (diff) | |
download | ale-06a97a854191b331b6ec37ef7ea0c59f671b1101.zip |
Use Makefile output with clang-tidy when useful
In the case where neither a build directory nor a compile_commands.json
file is found, use the output of `make -n` to provide options to
clang-tidy.
Diffstat (limited to 'ale_linters/cpp')
-rw-r--r-- | ale_linters/cpp/clangtidy.vim | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ale_linters/cpp/clangtidy.vim b/ale_linters/cpp/clangtidy.vim index 085bc332..7c8defa4 100644 --- a/ale_linters/cpp/clangtidy.vim +++ b/ale_linters/cpp/clangtidy.vim @@ -13,14 +13,18 @@ call ale#Set('cpp_clangtidy_options', '') call ale#Set('cpp_clangtidy_extra_options', '') call ale#Set('c_build_dir', '') -function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort +function! ale_linters#cpp#clangtidy#GetCommand(buffer, output) abort let l:checks = join(ale#Var(a:buffer, 'cpp_clangtidy_checks'), ',') let l:build_dir = ale#c#GetBuildDirectory(a:buffer) " Get the extra options if we couldn't find a build directory. - let l:options = empty(l:build_dir) - \ ? ale#Var(a:buffer, 'cpp_clangtidy_options') - \ : '' + let l:options = '' + + if empty(l:build_dir) + let l:options = ale#Var(a:buffer, 'cpp_clangtidy_options') + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags + endif " Get the options to pass directly to clang-tidy let l:extra_options = ale#Var(a:buffer, 'cpp_clangtidy_extra_options') @@ -37,7 +41,7 @@ call ale#linter#Define('cpp', { \ 'name': 'clangtidy', \ 'output_stream': 'stdout', \ 'executable': {b -> ale#Var(b, 'cpp_clangtidy_executable')}, -\ 'command': function('ale_linters#cpp#clangtidy#GetCommand'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#clangtidy#GetCommand'))}, \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'lint_file': 1, \}) |