summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-08-02 21:48:56 +0100
committerw0rp <devw0rp@gmail.com>2018-08-02 21:48:56 +0100
commit94270402cb5c28017061c383c40dff89008d0125 (patch)
treed730dfca2b016aa5d7b1651ef45008e97ceda9d3
parentccbdfcd76fe74232ee507d47f7edd9d447e3656a (diff)
downloadale-94270402cb5c28017061c383c40dff89008d0125.zip
Fall back on flags for other C/C++ files in the same directory
-rw-r--r--autoload/ale/c.vim10
1 files changed, 10 insertions, 0 deletions
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index 19bb0d5e..d4207e76 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -150,12 +150,22 @@ function! s:GetListFromCompileCommandsFile(compile_commands_file) abort
endfunction
function! ale#c#ParseCompileCommandsFlags(buffer, dir, json_list) abort
+ " Search for an exact file match first.
for l:item in a:json_list
if bufnr(l:item.file) is a:buffer
return ale#c#ParseCFlags(a:dir, l:item.command)
endif
endfor
+ " Look for any file in the same directory if we can't find an exact match.
+ let l:dir = ale#path#Simplify(expand('#' . a:buffer . ':p:h'))
+
+ for l:item in a:json_list
+ if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir
+ return ale#c#ParseCFlags(a:dir, l:item.command)
+ endif
+ endfor
+
return ''
endfunction