diff options
author | w0rp <w0rp@users.noreply.github.com> | 2020-08-19 00:21:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-19 00:21:22 +0100 |
commit | 92cada99134dd38d441b7a5a55ddbe7d58882c96 (patch) | |
tree | 784be8c73bc3d85750e3ed86927e699be8667ce5 /ale_linters/cpp | |
parent | e27d4377b5dec30a6510a8d45685a37681baaaf0 (diff) | |
parent | fc6677d40565f4c84730a7cfb0af186f183be031 (diff) | |
download | ale-92cada99134dd38d441b7a5a55ddbe7d58882c96.zip |
Merge pull request #3056 from ts826848/remove-ale-std-if-already-in-GetCFlags
[WIP] Avoid overriding parsed C/C++ -std=* flag
Diffstat (limited to 'ale_linters/cpp')
-rw-r--r-- | ale_linters/cpp/clang.vim | 11 | ||||
-rw-r--r-- | ale_linters/cpp/gcc.vim | 11 |
2 files changed, 20 insertions, 2 deletions
diff --git a/ale_linters/cpp/clang.vim b/ale_linters/cpp/clang.vim index e48291eb..d93638ec 100644 --- a/ale_linters/cpp/clang.vim +++ b/ale_linters/cpp/clang.vim @@ -6,13 +6,22 @@ call ale#Set('cpp_clang_options', '-std=c++14 -Wall') function! ale_linters#cpp#clang#GetCommand(buffer, output) abort let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:ale_flags = ale#Var(a:buffer, 'cpp_clang_options') + + if l:cflags =~# '-std=' + let l:ale_flags = substitute( + \ l:ale_flags, + \ '-std=\(c\|gnu\)++[0-9]\{2\}', + \ '', + \ 'g') + endif " -iquote with the directory the file is in makes #include work for " headers in the same directory. return '%e -S -x c++ -fsyntax-only' \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) \ . ale#Pad(l:cflags) - \ . ale#Pad(ale#Var(a:buffer, 'cpp_clang_options')) . ' -' + \ . ale#Pad(l:ale_flags) . ' -' endfunction call ale#linter#Define('cpp', { diff --git a/ale_linters/cpp/gcc.vim b/ale_linters/cpp/gcc.vim index 108d6d70..89c2d358 100644 --- a/ale_linters/cpp/gcc.vim +++ b/ale_linters/cpp/gcc.vim @@ -6,6 +6,15 @@ call ale#Set('cpp_gcc_options', '-std=c++14 -Wall') function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:ale_flags = ale#Var(a:buffer, 'cpp_gcc_options') + + if l:cflags =~# '-std=' + let l:ale_flags = substitute( + \ l:ale_flags, + \ '-std=\(c\|gnu\)++[0-9]\{2\}', + \ '', + \ 'g') + endif " -iquote with the directory the file is in makes #include work for " headers in the same directory. @@ -16,7 +25,7 @@ function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort \ . ' -o ' . g:ale#util#nul_file \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) \ . ale#Pad(l:cflags) - \ . ale#Pad(ale#Var(a:buffer, 'cpp_gcc_options')) . ' -' + \ . ale#Pad(l:ale_flags) . ' -' endfunction call ale#linter#Define('cpp', { |