mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Merge pull request #3056 from ts826848/remove-ale-std-if-already-in-GetCFlags
[WIP] Avoid overriding parsed C/C++ -std=* flag
This commit is contained in:
@@ -6,13 +6,22 @@ call ale#Set('c_clang_options', '-std=c11 -Wall')
|
|||||||
|
|
||||||
function! ale_linters#c#clang#GetCommand(buffer, output) abort
|
function! ale_linters#c#clang#GetCommand(buffer, output) abort
|
||||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
||||||
|
let l:ale_flags = ale#Var(a:buffer, 'c_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
|
" -iquote with the directory the file is in makes #include work for
|
||||||
" headers in the same directory.
|
" headers in the same directory.
|
||||||
return '%e -S -x c -fsyntax-only'
|
return '%e -S -x c -fsyntax-only'
|
||||||
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||||
\ . ale#Pad(l:cflags)
|
\ . ale#Pad(l:cflags)
|
||||||
\ . ale#Pad(ale#Var(a:buffer, 'c_clang_options')) . ' -'
|
\ . ale#Pad(l:ale_flags) . ' -'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('c', {
|
call ale#linter#Define('c', {
|
||||||
|
|||||||
@@ -6,6 +6,15 @@ call ale#Set('c_gcc_options', '-std=c11 -Wall')
|
|||||||
|
|
||||||
function! ale_linters#c#gcc#GetCommand(buffer, output) abort
|
function! ale_linters#c#gcc#GetCommand(buffer, output) abort
|
||||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
||||||
|
let l:ale_flags = ale#Var(a:buffer, 'c_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
|
" -iquote with the directory the file is in makes #include work for
|
||||||
" headers in the same directory.
|
" headers in the same directory.
|
||||||
@@ -16,7 +25,7 @@ function! ale_linters#c#gcc#GetCommand(buffer, output) abort
|
|||||||
\ . ' -o ' . g:ale#util#nul_file
|
\ . ' -o ' . g:ale#util#nul_file
|
||||||
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||||
\ . ale#Pad(l:cflags)
|
\ . ale#Pad(l:cflags)
|
||||||
\ . ale#Pad(ale#Var(a:buffer, 'c_gcc_options')) . ' -'
|
\ . ale#Pad(l:ale_flags) . ' -'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('c', {
|
call ale#linter#Define('c', {
|
||||||
|
|||||||
@@ -6,13 +6,22 @@ call ale#Set('cpp_clang_options', '-std=c++14 -Wall')
|
|||||||
|
|
||||||
function! ale_linters#cpp#clang#GetCommand(buffer, output) abort
|
function! ale_linters#cpp#clang#GetCommand(buffer, output) abort
|
||||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
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
|
" -iquote with the directory the file is in makes #include work for
|
||||||
" headers in the same directory.
|
" headers in the same directory.
|
||||||
return '%e -S -x c++ -fsyntax-only'
|
return '%e -S -x c++ -fsyntax-only'
|
||||||
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||||
\ . ale#Pad(l:cflags)
|
\ . ale#Pad(l:cflags)
|
||||||
\ . ale#Pad(ale#Var(a:buffer, 'cpp_clang_options')) . ' -'
|
\ . ale#Pad(l:ale_flags) . ' -'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('cpp', {
|
call ale#linter#Define('cpp', {
|
||||||
|
|||||||
@@ -6,6 +6,15 @@ call ale#Set('cpp_gcc_options', '-std=c++14 -Wall')
|
|||||||
|
|
||||||
function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort
|
function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort
|
||||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
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
|
" -iquote with the directory the file is in makes #include work for
|
||||||
" headers in the same directory.
|
" headers in the same directory.
|
||||||
@@ -16,7 +25,7 @@ function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort
|
|||||||
\ . ' -o ' . g:ale#util#nul_file
|
\ . ' -o ' . g:ale#util#nul_file
|
||||||
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||||
\ . ale#Pad(l:cflags)
|
\ . ale#Pad(l:cflags)
|
||||||
\ . ale#Pad(ale#Var(a:buffer, 'cpp_gcc_options')) . ' -'
|
\ . ale#Pad(l:ale_flags) . ' -'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('cpp', {
|
call ale#linter#Define('cpp', {
|
||||||
|
|||||||
Reference in New Issue
Block a user