summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2019-10-07 19:34:52 +0100
committerGitHub <noreply@github.com>2019-10-07 19:34:52 +0100
commitf2b231dd76b017d43b89ead4931a37237beb3494 (patch)
treeb6cff20c777c9462297babc29050b0ca8add08fd /ale_linters
parent8fda1cebff2f7f07972214a41babbb0620e5d9e8 (diff)
parent779589884164552442cab8ab077fa37afc7317fd (diff)
downloadale-f2b231dd76b017d43b89ead4931a37237beb3494.zip
Merge pull request #2771 from gpanders/master
Use Makefile output with clang-tidy when useful
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/c/clangtidy.vim13
-rw-r--r--ale_linters/cpp/clangtidy.vim13
2 files changed, 16 insertions, 10 deletions
diff --git a/ale_linters/c/clangtidy.vim b/ale_linters/c/clangtidy.vim
index f998866a..553cc23b 100644
--- a/ale_linters/c/clangtidy.vim
+++ b/ale_linters/c/clangtidy.vim
@@ -19,14 +19,17 @@ call ale#Set('c_clangtidy_options', '')
call ale#Set('c_clangtidy_extra_options', '')
call ale#Set('c_build_dir', '')
-function! ale_linters#c#clangtidy#GetCommand(buffer) abort
+function! ale_linters#c#clangtidy#GetCommand(buffer, output) abort
let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',')
let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
+ let l:options = ''
" Get the extra options if we couldn't find a build directory.
- let l:options = empty(l:build_dir)
- \ ? ale#Var(a:buffer, 'c_clangtidy_options')
- \ : ''
+ if empty(l:build_dir)
+ let l:options = ale#Var(a:buffer, 'c_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, 'c_clangtidy_extra_options')
@@ -43,7 +46,7 @@ call ale#linter#Define('c', {
\ 'name': 'clangtidy',
\ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'c_clangtidy_executable')},
-\ 'command': function('ale_linters#c#clangtidy#GetCommand'),
+\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#clangtidy#GetCommand'))},
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1,
\})
diff --git a/ale_linters/cpp/clangtidy.vim b/ale_linters/cpp/clangtidy.vim
index 085bc332..191b7b07 100644
--- a/ale_linters/cpp/clangtidy.vim
+++ b/ale_linters/cpp/clangtidy.vim
@@ -13,14 +13,17 @@ 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)
+ let l:options = ''
" 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')
- \ : ''
+ 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 +40,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,
\})