diff options
author | w0rp <devw0rp@gmail.com> | 2019-04-15 21:38:11 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2019-04-15 21:38:11 +0100 |
commit | 23a8208498047c98108ca74f63ace023ecb1c232 (patch) | |
tree | 9a904654673e399117a7bb4053622829c591404e /autoload | |
parent | 7f31065fce89cca492c21c8bd73c74aa9f9432b2 (diff) | |
download | ale-23a8208498047c98108ca74f63ace023ecb1c232.zip |
#782 - Use compile commands for matching source files for headers
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/c.vim | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim index eeb512ba..a9289e22 100644 --- a/autoload/ale/c.vim +++ b/autoload/ale/c.vim @@ -219,9 +219,32 @@ 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, []) + " A source file matching the header filename. + let l:source_file = '' + + if empty(l:file_list) && l:basename =~? '\.h$\|\.hpp$' + for l:suffix in ['.c', '.cpp'] + let l:key = fnamemodify(l:basename, ':r') . l:suffix + let l:file_list = get(a:file_lookup, l:key, []) + + if !empty(l:file_list) + let l:source_file = l:key + break + endif + endfor + endif for l:item in l:file_list - if bufnr(l:item.file) is a:buffer && has_key(l:item, 'command') + " Load the flags for this file, or for a source file matching the + " header file. + if has_key(l:item, 'command') + \&& ( + \ bufnr(l:item.file) is a:buffer + \ || ( + \ !empty(l:source_file) + \ && l:item.file[-len(l:source_file):] is? l:source_file + \ ) + \) return ale#c#ParseCFlags(l:item.directory, l:item.command) endif endfor |