From 94270402cb5c28017061c383c40dff89008d0125 Mon Sep 17 00:00:00 2001 From: w0rp Date: Thu, 2 Aug 2018 21:48:56 +0100 Subject: [PATCH] Fall back on flags for other C/C++ files in the same directory --- autoload/ale/c.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) 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