diff options
author | Nicolas Pauss <nicolas.pauss@intersec.com> | 2022-10-12 00:05:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-12 07:05:37 +0900 |
commit | 951a668b1490f0b3dcdcec6b4ebf3f626c0f416f (patch) | |
tree | 48eac8f7911b6fcfc1ad47ef02f84416628ccfcd /ale_linters/c/cc.vim | |
parent | f085227504076dff5224cbf10cb1bf83286188a9 (diff) | |
download | ale-951a668b1490f0b3dcdcec6b4ebf3f626c0f416f.zip |
cc: fix using '-x c*-header' for header files with GCC. (#4334)
Gcc does not support `x c*-header` when using `-` as input filename,
which is what ALE does.
Rework the feature to only use `-x c*-header` flag when using Clang and
not GCC.
The feature is now also controlled with the variable
`g:ale_c_cc_use_header_lang_flag` and
`g:ale_cpp_cc_use_header_lang_flag`.
Diffstat (limited to 'ale_linters/c/cc.vim')
-rw-r--r-- | ale_linters/c/cc.vim | 15 |
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. " |