]> git.madduck.net Git - etc/vim.git/blob - ale_linters/vim/vimls.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / ale_linters / vim / vimls.vim
1 " Author: Jeffrey Lau - https://github.com/zoonfafer
2 " Description: Vim Language Server integration for ALE
3
4 call ale#Set('vim_vimls_executable', 'vim-language-server')
5 call ale#Set('vim_vimls_use_global', get(g:, 'ale_use_global_executables', 0))
6 call ale#Set('vim_vimls_config', {})
7
8 function! ale_linters#vim#vimls#GetProjectRoot(buffer) abort
9     let l:trigger_file_candidates = [
10     \   '.vimrc',
11     \   'init.vim',
12     \]
13
14     for l:candidate in l:trigger_file_candidates
15         let l:trigger_file = fnamemodify(bufname(a:buffer), ':t')
16
17         if l:trigger_file is# l:candidate
18             return fnamemodify(
19             \   bufname(a:buffer),
20             \   ':h',
21             \)
22         endif
23     endfor
24
25     let l:trigger_dir_candidates = [
26     \   'autoload',
27     \   'plugin',
28     \   '.git',
29     \]
30
31     let l:path_upwards = ale#path#Upwards(fnamemodify(bufname(a:buffer), ':p:h'))
32
33     for l:path in l:path_upwards
34         for l:candidate in l:trigger_dir_candidates
35             let l:trigger_dir = ale#path#Simplify(
36             \   l:path . '/' . l:candidate,
37             \)
38
39             if isdirectory(l:trigger_dir)
40                 return fnamemodify(
41                 \   l:trigger_dir,
42                 \   ':p:h:h',
43                 \)
44             endif
45         endfor
46     endfor
47
48     return ''
49 endfunction
50
51 call ale#linter#Define('vim', {
52 \   'name': 'vimls',
53 \   'lsp': 'stdio',
54 \   'lsp_config': {b -> ale#Var(b, 'vim_vimls_config')},
55 \   'executable': {b -> ale#path#FindExecutable(b, 'vim_vimls', [
56 \       'node_modules/.bin/vim-language-server',
57 \   ])},
58 \   'command': '%e --stdio',
59 \   'language': 'vim',
60 \   'project_root': function('ale_linters#vim#vimls#GetProjectRoot'),
61 \})