summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-03-27 09:55:43 +0100
committerGitHub <noreply@github.com>2018-03-27 09:55:43 +0100
commit018831d601a6fc53216ad448a91bb76b0ac4d8e3 (patch)
tree5a34d094612bc4acbfc5500ef21282ac45a1adbd /ale_linters
parent27c5faeafe055954b6e3164467844e78f7a07e55 (diff)
parentdfb3e194d7a05b747c77d312a72e5149595bbcef (diff)
downloadale-018831d601a6fc53216ad448a91bb76b0ac4d8e3.zip
Merge pull request #1434 from roel0/master
Automatically determine build flags by parsing `make -n` output #1167
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/c/clang.vim11
-rw-r--r--ale_linters/c/gcc.vim11
2 files changed, 14 insertions, 8 deletions
diff --git a/ale_linters/c/clang.vim b/ale_linters/c/clang.vim
index 76803056..ddec4fcb 100644
--- a/ale_linters/c/clang.vim
+++ b/ale_linters/c/clang.vim
@@ -8,15 +8,15 @@ function! ale_linters#c#clang#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'c_clang_executable')
endfunction
-function! ale_linters#c#clang#GetCommand(buffer) abort
- let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
+function! ale_linters#c#clang#GetCommand(buffer, output) abort
+ let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
return ale#Escape(ale_linters#c#clang#GetExecutable(a:buffer))
\ . ' -S -x c -fsyntax-only '
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
- \ . ale#c#IncludeOptions(l:paths)
+ \ . l:cflags
\ . ale#Var(a:buffer, 'c_clang_options') . ' -'
endfunction
@@ -24,6 +24,9 @@ call ale#linter#Define('c', {
\ 'name': 'clang',
\ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#c#clang#GetExecutable',
-\ 'command_callback': 'ale_linters#c#clang#GetCommand',
+\ 'command_chain': [
+\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
+\ {'callback': 'ale_linters#c#clang#GetCommand'}
+\ ],
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\})
diff --git a/ale_linters/c/gcc.vim b/ale_linters/c/gcc.vim
index 4b241e37..98563952 100644
--- a/ale_linters/c/gcc.vim
+++ b/ale_linters/c/gcc.vim
@@ -8,15 +8,15 @@ function! ale_linters#c#gcc#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'c_gcc_executable')
endfunction
-function! ale_linters#c#gcc#GetCommand(buffer) abort
- let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
+function! ale_linters#c#gcc#GetCommand(buffer, output) abort
+ let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
return ale#Escape(ale_linters#c#gcc#GetExecutable(a:buffer))
\ . ' -S -x c -fsyntax-only '
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
- \ . ale#c#IncludeOptions(l:paths)
+ \ . l:cflags
\ . ale#Var(a:buffer, 'c_gcc_options') . ' -'
endfunction
@@ -24,6 +24,9 @@ call ale#linter#Define('c', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#c#gcc#GetExecutable',
-\ 'command_callback': 'ale_linters#c#gcc#GetCommand',
+\ 'command_chain': [
+\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
+\ {'callback': 'ale_linters#c#gcc#GetCommand'}
+\ ],
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\})