summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-07-25 21:07:19 +0100
committerGitHub <noreply@github.com>2018-07-25 21:07:19 +0100
commit79ffdde267323a206a96227904549c370f27decf (patch)
tree86f3af9e70a4d13ab7715d39a3395a348dde8bcc /ale_linters
parentc52fffcd47d1985f420eb84b2be20cc6c25c3cea (diff)
parentc57b0318767f0c03c7ebbe7ca39ab45b33e57096 (diff)
downloadale-79ffdde267323a206a96227904549c370f27decf.zip
Merge pull request #1757 from jtalowell/master
Providing cquery support for C files
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/c/cquery.vim32
1 files changed, 32 insertions, 0 deletions
diff --git a/ale_linters/c/cquery.vim b/ale_linters/c/cquery.vim
new file mode 100644
index 00000000..208c226f
--- /dev/null
+++ b/ale_linters/c/cquery.vim
@@ -0,0 +1,32 @@
+" 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',
+\})