2018-06-06 12:03:15 -04:00
|
|
|
" Author: Ben Falconer <ben@falconers.me.uk>
|
|
|
|
" Description: A language server for C++
|
|
|
|
|
|
|
|
call ale#Set('cpp_cquery_executable', 'cquery')
|
|
|
|
call ale#Set('cpp_cquery_cache_directory', expand('~/.cache/cquery'))
|
|
|
|
|
|
|
|
function! ale_linters#cpp#cquery#GetProjectRoot(buffer) abort
|
|
|
|
let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
|
2018-08-08 23:06:30 -04:00
|
|
|
|
2018-08-06 15:33:25 -04:00
|
|
|
if empty(l:project_root)
|
|
|
|
let l:project_root = ale#path#FindNearestFile(a:buffer, '.cquery')
|
|
|
|
endif
|
2018-08-08 23:06:30 -04:00
|
|
|
|
2018-06-06 19:04:21 -04:00
|
|
|
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
|
2018-06-06 12:03:15 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#cpp#cquery#GetInitializationOptions(buffer) abort
|
|
|
|
return {'cacheDirectory': ale#Var(a:buffer, 'cpp_cquery_cache_directory')}
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('cpp', {
|
|
|
|
\ 'name': 'cquery',
|
|
|
|
\ 'lsp': 'stdio',
|
2018-08-02 18:44:12 -04:00
|
|
|
\ 'executable_callback': ale#VarFunc('cpp_cquery_executable'),
|
|
|
|
\ 'command': '%e',
|
2018-06-06 12:03:15 -04:00
|
|
|
\ 'project_root_callback': 'ale_linters#cpp#cquery#GetProjectRoot',
|
|
|
|
\ 'initialization_options_callback': 'ale_linters#cpp#cquery#GetInitializationOptions',
|
|
|
|
\})
|