1
0
Fork 0
mirror of synced 2024-11-17 22:45:34 -05:00
ultimate-vim/sources_non_forked/ale/ale_linters/c/cquery.vim

33 lines
1.3 KiB
VimL
Raw Normal View History

2018-07-30 17:18:16 -04: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')
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction
function! ale_linters#c#cquery#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'c_cquery_executable')
endfunction
function! ale_linters#c#cquery#GetCommand(buffer) abort
let l:executable = ale_linters#c#cquery#GetExecutable(a:buffer)
return ale#Escape(l:executable)
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',
\ 'executable_callback': 'ale_linters#c#cquery#GetExecutable',
\ 'command_callback': 'ale_linters#c#cquery#GetCommand',
\ 'project_root_callback': 'ale_linters#c#cquery#GetProjectRoot',
\ 'initialization_options_callback': 'ale_linters#c#cquery#GetInitializationOptions',
\})