summaryrefslogtreecommitdiff
path: root/ale_linters/c/cc.vim
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters/c/cc.vim')
-rw-r--r--ale_linters/c/cc.vim15
1 files changed, 13 insertions, 2 deletions
diff --git a/ale_linters/c/cc.vim b/ale_linters/c/cc.vim
index d0215041..35125f2f 100644
--- a/ale_linters/c/cc.vim
+++ b/ale_linters/c/cc.vim
@@ -3,6 +3,7 @@
call ale#Set('c_cc_executable', '<auto>')
call ale#Set('c_cc_options', '-std=c11 -Wall')
+call ale#Set('c_cc_use_header_lang_flag', -1)
call ale#Set('c_cc_header_exts', ['h'])
function! ale_linters#c#cc#GetExecutable(buffer) abort
@@ -23,8 +24,6 @@ endfunction
function! ale_linters#c#cc#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
let l:ale_flags = ale#Var(a:buffer, 'c_cc_options')
- let l:header_exts = ale#Var(a:buffer, 'c_cc_header_exts')
- let l:lang_flag = ale#c#GetLanguageFlag(a:buffer, l:header_exts, 'c')
if l:cflags =~# '-std='
let l:ale_flags = substitute(
@@ -34,6 +33,18 @@ function! ale_linters#c#cc#GetCommand(buffer, output) abort
\ 'g')
endif
+ " Select the correct language flag depending on the executable, options
+ " and file extension
+ let l:executable = ale_linters#c#cc#GetExecutable(a:buffer)
+ let l:use_header_lang_flag = ale#Var(a:buffer, 'c_cc_use_header_lang_flag')
+ let l:header_exts = ale#Var(a:buffer, 'c_cc_header_exts')
+ let l:lang_flag = ale#c#GetLanguageFlag(
+ \ a:buffer,
+ \ l:executable,
+ \ l:use_header_lang_flag,
+ \ l:header_exts,
+ \ 'c')
+
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
"