diff options
author | Bjorn Neergaard <bjorn@neersighted.com> | 2018-11-29 14:57:35 -0700 |
---|---|---|
committer | Bjorn Neergaard <bjorn@neersighted.com> | 2018-11-29 14:57:35 -0700 |
commit | d2b0ae8108b2ee395d4eb43c49d68b322a023a30 (patch) | |
tree | bb8145e69bf1bcb8968b29cb1a68c47ceb83674d /ale_linters/c/cquery.vim | |
parent | ef641dda80f45cb979bc93c2513c6e10cbd8e42a (diff) | |
parent | 0a384a49d371838903d8401c5358ec60f3f4266d (diff) | |
download | ale-d2b0ae8108b2ee395d4eb43c49d68b322a023a30.zip |
Merge branch 'master' into sridhars
Diffstat (limited to 'ale_linters/c/cquery.vim')
-rw-r--r-- | ale_linters/c/cquery.vim | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ale_linters/c/cquery.vim b/ale_linters/c/cquery.vim new file mode 100644 index 00000000..a20782a2 --- /dev/null +++ b/ale_linters/c/cquery.vim @@ -0,0 +1,28 @@ +" 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') + + if empty(l:project_root) + let l:project_root = ale#path#FindNearestFile(a:buffer, '.cquery') + endif + + 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', +\ 'executable_callback': ale#VarFunc('c_cquery_executable'), +\ 'command': '%e', +\ 'project_root_callback': 'ale_linters#c#cquery#GetProjectRoot', +\ 'initialization_options_callback': 'ale_linters#c#cquery#GetInitializationOptions', +\}) |