diff options
Diffstat (limited to 'ale_linters/cpp/cquery.vim')
-rw-r--r-- | ale_linters/cpp/cquery.vim | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/ale_linters/cpp/cquery.vim b/ale_linters/cpp/cquery.vim new file mode 100644 index 00000000..dbaed520 --- /dev/null +++ b/ale_linters/cpp/cquery.vim @@ -0,0 +1,34 @@ +" 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') + + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h:h') : '' +endfunction + +function! ale_linters#cpp#cquery#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'cpp_cquery_executable') +endfunction + +function! ale_linters#cpp#cquery#GetCommand(buffer) abort + let l:executable = ale_linters#cpp#cquery#GetExecutable(a:buffer) + return ale#Escape(l:executable) +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', +\ 'executable_callback': 'ale_linters#cpp#cquery#GetExecutable', +\ 'command_callback': 'ale_linters#cpp#cquery#GetCommand', +\ 'project_root_callback': 'ale_linters#cpp#cquery#GetProjectRoot', +\ 'initialization_options_callback': 'ale_linters#cpp#cquery#GetInitializationOptions', +\ 'language': 'cpp', +\}) |