Move ccls functions to autoload/ale/handler
Tests are kept as-is.
This commit is contained in:
parent
17676f6a6d
commit
8891b7c349
@ -4,29 +4,11 @@
|
|||||||
call ale#Set('c_ccls_executable', 'ccls')
|
call ale#Set('c_ccls_executable', 'ccls')
|
||||||
call ale#Set('c_ccls_init_options', {})
|
call ale#Set('c_ccls_init_options', {})
|
||||||
|
|
||||||
function! ale_linters#c#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')
|
|
||||||
endif
|
|
||||||
|
|
||||||
if 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#c#ccls#GetInitializationOptions(buffer) abort
|
|
||||||
return ale#Var(a:buffer, 'c_ccls_init_options')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call ale#linter#Define('c', {
|
call ale#linter#Define('c', {
|
||||||
\ 'name': 'ccls',
|
\ 'name': 'ccls',
|
||||||
\ 'lsp': 'stdio',
|
\ 'lsp': 'stdio',
|
||||||
\ 'executable_callback': ale#VarFunc('c_ccls_executable'),
|
\ 'executable_callback': ale#VarFunc('c_ccls_executable'),
|
||||||
\ 'command': '%e',
|
\ 'command': '%e',
|
||||||
\ 'project_root_callback': 'ale_linters#c#ccls#GetProjectRoot',
|
\ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot',
|
||||||
\ 'initialization_options_callback': 'ale_linters#c#ccls#GetInitializationOptions',
|
\ 'initialization_options_callback':ale#VarFunc('c_ccls_init_options'),
|
||||||
\})
|
\})
|
||||||
|
@ -4,29 +4,11 @@
|
|||||||
call ale#Set('cpp_ccls_executable', 'ccls')
|
call ale#Set('cpp_ccls_executable', 'ccls')
|
||||||
call ale#Set('cpp_ccls_init_options', {})
|
call ale#Set('cpp_ccls_init_options', {})
|
||||||
|
|
||||||
function! ale_linters#cpp#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')
|
|
||||||
endif
|
|
||||||
|
|
||||||
if 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#cpp#ccls#GetInitializationOptions(buffer) abort
|
|
||||||
return ale#Var(a:buffer, 'cpp_ccls_init_options')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call ale#linter#Define('cpp', {
|
call ale#linter#Define('cpp', {
|
||||||
\ 'name': 'ccls',
|
\ 'name': 'ccls',
|
||||||
\ 'lsp': 'stdio',
|
\ 'lsp': 'stdio',
|
||||||
\ 'executable_callback': ale#VarFunc('cpp_ccls_executable'),
|
\ 'executable_callback': ale#VarFunc('cpp_ccls_executable'),
|
||||||
\ 'command': '%e',
|
\ 'command': '%e',
|
||||||
\ 'project_root_callback': 'ale_linters#cpp#ccls#GetProjectRoot',
|
\ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot',
|
||||||
\ 'initialization_options_callback': 'ale_linters#cpp#ccls#GetInitializationOptions',
|
\ 'initialization_options_callback': ale#VarFunc('cpp_ccls_init_options'),
|
||||||
\})
|
\})
|
||||||
|
@ -4,29 +4,11 @@
|
|||||||
call ale#Set('objc_ccls_executable', 'ccls')
|
call ale#Set('objc_ccls_executable', 'ccls')
|
||||||
call ale#Set('objc_ccls_init_options', {})
|
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')
|
|
||||||
endif
|
|
||||||
|
|
||||||
if 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', {
|
call ale#linter#Define('objc', {
|
||||||
\ 'name': 'ccls',
|
\ 'name': 'ccls',
|
||||||
\ 'lsp': 'stdio',
|
\ 'lsp': 'stdio',
|
||||||
\ 'executable_callback': ale#VarFunc('objc_ccls_executable'),
|
\ 'executable_callback': ale#VarFunc('objc_ccls_executable'),
|
||||||
\ 'command': '%e',
|
\ 'command': '%e',
|
||||||
\ 'project_root_callback': 'ale_linters#objc#ccls#GetProjectRoot',
|
\ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot',
|
||||||
\ 'initialization_options_callback': 'ale_linters#objc#ccls#GetInitializationOptions',
|
\ 'initialization_options_callback': ale#VarFunc('objc_ccls_init_options'),
|
||||||
\})
|
\})
|
||||||
|
17
autoload/ale/handlers/ccls.vim
Normal file
17
autoload/ale/handlers/ccls.vim
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
scriptencoding utf-8
|
||||||
|
" Author: Ye Jingchen <ye.jingchen@gmail.com>
|
||||||
|
" Description: Utilities for ccls
|
||||||
|
|
||||||
|
function! ale#handlers#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')
|
||||||
|
endif
|
||||||
|
|
||||||
|
if 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
|
Loading…
Reference in New Issue
Block a user