diff options
author | w0rp <devw0rp@gmail.com> | 2019-02-22 15:24:34 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2019-02-22 15:24:34 +0000 |
commit | f53b25d2567a2f7495dab444680596f48de427d1 (patch) | |
tree | 87768bc6ddaceaf5502df785b6b9fee6c5e516d6 /autoload | |
parent | f8aeb5c5a45b57a35d1572176e345173c6e4de61 (diff) | |
download | ale-f53b25d2567a2f7495dab444680596f48de427d1.zip |
#2132 - Implement project_root as a replacement for project_root_callback
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/linter.vim | 17 | ||||
-rw-r--r-- | autoload/ale/lsp_linter.vim | 6 |
2 files changed, 20 insertions, 3 deletions
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim index dba59893..74d5c14a 100644 --- a/autoload/ale/linter.vim +++ b/autoload/ale/linter.vim @@ -242,10 +242,21 @@ function! ale#linter#PreProcess(filetype, linter) abort endif endif - let l:obj.project_root_callback = get(a:linter, 'project_root_callback') + if has_key(a:linter, 'project_root') + let l:obj.project_root = a:linter.project_root - if !s:IsCallback(l:obj.project_root_callback) - throw '`project_root_callback` must be a callback for LSP linters' + if type(l:obj.project_root) isnot v:t_string + \&& type(l:obj.project_root) isnot v:t_func + throw '`project_root` must be a String or Function if defined' + endif + elseif has_key(a:linter, 'project_root_callback') + let l:obj.project_root_callback = a:linter.project_root_callback + + if !s:IsCallback(l:obj.project_root_callback) + throw '`project_root_callback` must be a callback if defined' + endif + else + throw '`project_root` or `project_root_callback` must be defined for LSP linters' endif if has_key(a:linter, 'completion_filter') diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim index b92f5104..d0f66bf7 100644 --- a/autoload/ale/lsp_linter.vim +++ b/autoload/ale/lsp_linter.vim @@ -194,6 +194,12 @@ function! ale#lsp_linter#FindProjectRoot(buffer, linter) abort endif " Fall back to the linter-specific configuration + if has_key(a:linter, 'project_root') + let l:Root = a:linter.project_root + + return type(l:Root) is v:t_func ? l:Root(a:buffer) : l:Root + endif + return ale#util#GetFunction(a:linter.project_root_callback)(a:buffer) endfunction |