diff options
author | w0rp <devw0rp@gmail.com> | 2019-05-20 22:08:03 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2019-05-20 22:08:03 +0100 |
commit | 28819eedd39f0746c94a1ec59ca3c089e35971a5 (patch) | |
tree | 2c51801dd80b97202add177d9fa4784eea75ed72 /ale_linters/c | |
parent | 937138dad4910e2746abcf34c9d0dc4ffb5454f3 (diff) | |
download | ale-28819eedd39f0746c94a1ec59ca3c089e35971a5.zip |
Close #2359 - Find compile_commands.json in build dirs for cppcheck
Diffstat (limited to 'ale_linters/c')
-rw-r--r-- | ale_linters/c/cppcheck.vim | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/ale_linters/c/cppcheck.vim b/ale_linters/c/cppcheck.vim index 851f9f11..b2ded90f 100644 --- a/ale_linters/c/cppcheck.vim +++ b/ale_linters/c/cppcheck.vim @@ -9,19 +9,16 @@ function! ale_linters#c#cppcheck#GetCommand(buffer) abort " " If we find it, we'll `cd` to where the compile_commands.json file is, " then use the file to set up import paths, etc. - let l:compile_commmands_path = ale#path#FindNearestFile(a:buffer, 'compile_commands.json') - - let l:cd_command = !empty(l:compile_commmands_path) - \ ? ale#path#CdString(fnamemodify(l:compile_commmands_path, ':h')) - \ : '' - let l:compile_commands_option = !empty(l:compile_commmands_path) - \ ? '--project=compile_commands.json ' + let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer) + let l:cd_command = !empty(l:dir) ? ale#path#CdString(l:dir) : '' + let l:compile_commands_option = !empty(l:json_path) + \ ? '--project=' . ale#Escape(l:json_path[len(l:dir) + 1: ]) \ : '' return l:cd_command - \ . '%e -q --language=c ' - \ . l:compile_commands_option - \ . ale#Var(a:buffer, 'c_cppcheck_options') + \ . '%e -q --language=c' + \ . ale#Pad(l:compile_commands_option) + \ . ale#Pad(ale#Var(a:buffer, 'c_cppcheck_options')) \ . ' %t' endfunction |