summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorDavid VandeBunte <david.vandebunte@here.com>2019-01-06 20:17:32 -0600
committerDavid VandeBunte <david.vandebunte@here.com>2019-01-08 19:09:02 -0600
commit4f72023e16fab3d7df53e3b1acea87ccb58be90b (patch)
tree1c15709f8a33de625d399b5797a715cfaddd484c /autoload
parentf23811770a8104346b7e9ccc6e586da828c8f41d (diff)
downloadale-4f72023e16fab3d7df53e3b1acea87ccb58be90b.zip
bugfix: c.vim: Pull build directory from compilation database
The LLVM compiler database JSON already includes a directory where the build was performed: https://clang.llvm.org/docs/JSONCompilationDatabase.html Prefer this directory for fixing relative paths in compiler include arguments in ale#c#ParseCFlags. Without this change, users cannot create a symlink to their compilation database as suggested in the LLVM tooling setup instructions: https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/c.vim9
1 files changed, 4 insertions, 5 deletions
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index 746d19b0..6175082e 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -200,14 +200,14 @@ function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort
return l:empty
endfunction
-function! ale#c#ParseCompileCommandsFlags(buffer, dir, file_lookup, dir_lookup) abort
+function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort
" Search for an exact file match first.
let l:basename = tolower(expand('#' . a:buffer . ':t'))
let l:file_list = get(a:file_lookup, l:basename, [])
for l:item in l:file_list
if bufnr(l:item.file) is a:buffer
- return ale#c#ParseCFlags(a:dir, l:item.command)
+ return ale#c#ParseCFlags(l:item.directory, l:item.command)
endif
endfor
@@ -219,7 +219,7 @@ function! ale#c#ParseCompileCommandsFlags(buffer, dir, file_lookup, dir_lookup)
for l:item in l:dir_list
if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir
- return ale#c#ParseCFlags(a:dir, l:item.command)
+ return ale#c#ParseCFlags(l:item.directory, l:item.command)
endif
endfor
@@ -227,12 +227,11 @@ function! ale#c#ParseCompileCommandsFlags(buffer, dir, file_lookup, dir_lookup)
endfunction
function! ale#c#FlagsFromCompileCommands(buffer, compile_commands_file) abort
- let l:dir = ale#path#Dirname(a:compile_commands_file)
let l:lookups = s:GetLookupFromCompileCommandsFile(a:compile_commands_file)
let l:file_lookup = l:lookups[0]
let l:dir_lookup = l:lookups[1]
- return ale#c#ParseCompileCommandsFlags(a:buffer, l:dir, l:file_lookup, l:dir_lookup)
+ return ale#c#ParseCompileCommandsFlags(a:buffer, l:file_lookup, l:dir_lookup)
endfunction
function! ale#c#GetCFlags(buffer, output) abort