summaryrefslogtreecommitdiff
path: root/ale_linters/objc
diff options
context:
space:
mode:
authorYe Jingchen <ye.jingchen@gmail.com>2018-09-26 20:09:37 +0800
committerYe Jingchen <ye.jingchen@gmail.com>2018-09-26 20:09:37 +0800
commit56658fd3ada284a373afffb49b0ec2d66ad00445 (patch)
tree7b34083c1cda56e9cdc02239e73c3a2f5d8f513f /ale_linters/objc
parent143c3cd09f52996c90b78059275a400d3c2327b0 (diff)
downloadale-56658fd3ada284a373afffb49b0ec2d66ad00445.zip
Add ccls support for C/C++/ObjC
Diffstat (limited to 'ale_linters/objc')
-rw-r--r--ale_linters/objc/ccls.vim30
1 files changed, 30 insertions, 0 deletions
diff --git a/ale_linters/objc/ccls.vim b/ale_linters/objc/ccls.vim
new file mode 100644
index 00000000..f354c7d7
--- /dev/null
+++ b/ale_linters/objc/ccls.vim
@@ -0,0 +1,30 @@
+" Author: Ye Jingchen <ye.jingchen@gmail.com>, Ben Falconer <ben@falconers.me.uk>, jtalowell <jtalowell@protonmail.com>
+" Description: A language server for Objective-C
+
+call ale#Set('objc_ccls_executable', 'ccls')
+call ale#Set('objc_ccls_init_options', {})
+
+function! ale_linters#objc#ccls#GetProjectRoot(buffer) abort
+ let l:project_root = ale#path#FindNearestFile(a:buffer, '.ccls-root')
+
+ if empty(l:project_root)
+ let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
+ elseif empty(l:project_root)
+ let l:project_root = ale#path#FindNearestFile(a:buffer, '.ccls')
+ endif
+
+ return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
+endfunction
+
+function! ale_linters#objc#ccls#GetInitializationOptions(buffer) abort
+ return ale#Var(a:buffer, 'objc_ccls_init_options')
+endfunction
+
+call ale#linter#Define('objc', {
+\ 'name': 'ccls',
+\ 'lsp': 'stdio',
+\ 'executable_callback': ale#VarFunc('objc_ccls_executable'),
+\ 'command': '%e',
+\ 'project_root_callback': 'ale_linters#objc#ccls#GetProjectRoot',
+\ 'initialization_options_callback': 'ale_linters#objc#ccls#GetInitializationOptions',
+\})