diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim index a79ab595ad..30d522b622 100644 --- a/autoload/ale/c.vim +++ b/autoload/ale/c.vim @@ -140,33 +140,43 @@ function! ale#c#ParseCFlags(path_prefix, should_quote, raw_arguments) abort let l:items = [] let l:option_index = 0 + " Options that can have a relative path as argument or attached. + let l:path_opts + \ = [ '-I', '-iquote', '-isystem', '-idirafter', '-iframework' ] + while l:option_index < len(l:arguments) let l:option = l:arguments[l:option_index] let l:option_index = l:option_index + 1 " Include options, that may need relative path fix - if stridx(l:option, '-I') == 0 - \ || stridx(l:option, '-iquote') == 0 - \ || stridx(l:option, '-isystem') == 0 - \ || stridx(l:option, '-idirafter') == 0 - \ || stridx(l:option, '-iframework') == 0 - if stridx(l:option, '-I') == 0 && l:option isnot# '-I' - let l:arg = join(split(l:option, '\zs')[2:], '') - let l:option = '-I' - else - let l:arg = l:arguments[l:option_index] - let l:option_index = l:option_index + 1 - endif + let l:did_relpath = v:false + for l:opt in l:path_opts + if stridx(l:option, l:opt) == 0 + if l:option is# l:opt " with a space, e.g. -iquote