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