diff options
author | Bartek thindil Jasicki <thindil@laeran.pl> | 2020-06-07 09:26:06 +0200 |
---|---|---|
committer | Bartek thindil Jasicki <thindil@laeran.pl> | 2020-06-07 09:26:06 +0200 |
commit | a5e7f2c8bb61f3e882bc26ce1773b130d1fbc32b (patch) | |
tree | cb85bc818b667acc9b28870755e079e20b935a3f /ale_linters/vim | |
parent | b6828ac5c54c809336b5314e51f185124d90b23f (diff) | |
parent | 7265ceb6d050d1a4642741d248f11e4f2abd37e1 (diff) | |
download | ale-a5e7f2c8bb61f3e882bc26ce1773b130d1fbc32b.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'ale_linters/vim')
-rw-r--r-- | ale_linters/vim/vimls.vim | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/ale_linters/vim/vimls.vim b/ale_linters/vim/vimls.vim new file mode 100644 index 00000000..26014d66 --- /dev/null +++ b/ale_linters/vim/vimls.vim @@ -0,0 +1,61 @@ +" Author: Jeffrey Lau - https://github.com/zoonfafer +" Description: Vim Language Server integration for ALE + +call ale#Set('vim_vimls_executable', 'vim-language-server') +call ale#Set('vim_vimls_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('vim_vimls_config', {}) + +function! ale_linters#vim#vimls#GetProjectRoot(buffer) abort + let l:trigger_file_candidates = [ + \ '.vimrc', + \ 'init.vim', + \] + + for l:candidate in l:trigger_file_candidates + let l:trigger_file = fnamemodify(bufname(a:buffer), ':t') + + if l:trigger_file is# l:candidate + return fnamemodify( + \ bufname(a:buffer), + \ ':h', + \) + endif + endfor + + let l:trigger_dir_candidates = [ + \ 'autoload', + \ 'plugin', + \ '.git', + \] + + let l:path_upwards = ale#path#Upwards(fnamemodify(bufname(a:buffer), ':p:h')) + + for l:path in l:path_upwards + for l:candidate in l:trigger_dir_candidates + let l:trigger_dir = ale#path#Simplify( + \ l:path . '/' . l:candidate, + \) + + if isdirectory(l:trigger_dir) + return fnamemodify( + \ l:trigger_dir, + \ ':p:h:h', + \) + endif + endfor + endfor + + return '' +endfunction + +call ale#linter#Define('vim', { +\ 'name': 'vimls', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'vim_vimls_config')}, +\ 'executable': {b -> ale#node#FindExecutable(b, 'vim_vimls', [ +\ 'node_modules/.bin/vim-language-server', +\ ])}, +\ 'command': '%e --stdio', +\ 'language': 'vim', +\ 'project_root': function('ale_linters#vim#vimls#GetProjectRoot'), +\}) |