2018-06-06 16:03:15 +00: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
|
2019-05-20 18:57:08 +00:00
|
|
|
" Try to find cquery configuration files first.
|
|
|
|
let l:config = ale#path#FindNearestFile(a:buffer, '.cquery')
|
2018-08-09 03:06:30 +00:00
|
|
|
|
2019-05-20 18:57:08 +00:00
|
|
|
if !empty(l:config)
|
|
|
|
return fnamemodify(l:config, ':h')
|
2018-08-06 19:33:25 +00:00
|
|
|
endif
|
2018-08-09 03:06:30 +00:00
|
|
|
|
2019-05-20 18:57:08 +00:00
|
|
|
" Fall back on default project root detection.
|
|
|
|
return ale#c#FindProjectRoot(a:buffer)
|
2018-06-06 16:03:15 +00: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',
|
2019-02-22 18:05:04 +00:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'cpp_cquery_executable')},
|
2018-08-02 22:44:12 +00:00
|
|
|
\ 'command': '%e',
|
2019-02-22 18:05:04 +00:00
|
|
|
\ 'project_root': function('ale_linters#cpp#cquery#GetProjectRoot'),
|
|
|
|
\ 'initialization_options': function('ale_linters#cpp#cquery#GetInitializationOptions'),
|
2018-06-06 16:03:15 +00:00
|
|
|
\})
|