diff options
author | Ben Falconer <ben@falconers.me.uk> | 2018-06-06 17:03:15 +0100 |
---|---|---|
committer | Ben Falconer <ben@falconers.me.uk> | 2018-06-06 17:58:47 +0100 |
commit | 20db9ab7197b6341644fcddc87f82c5731852ea8 (patch) | |
tree | 507190ec5e6bfa4f5c6c156b4857da097056f725 /ale_linters/cpp | |
parent | 641c0c797ba5dc4adac199fca4015d833a7e1f61 (diff) | |
download | ale-20db9ab7197b6341644fcddc87f82c5731852ea8.zip |
Add the cquery LSP #1475 #1594
Diffstat (limited to 'ale_linters/cpp')
-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', +\}) |