]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/erlang/erlang_ls.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:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / ale_linters / erlang / erlang_ls.vim
1 " Author: Dmitri Vereshchagin <dmitri.vereshchagin@gmail.com>
2 " Description: LSP linter for Erlang files
3
4 call ale#Set('erlang_erlang_ls_executable', 'erlang_ls')
5 call ale#Set('erlang_erlang_ls_log_dir', '')
6 call ale#Set('erlang_erlang_ls_log_level', 'info')
7
8 function! s:GetCommand(buffer) abort
9     let l:log_dir = ale#Var(a:buffer, 'erlang_erlang_ls_log_dir')
10     let l:log_level = ale#Var(a:buffer, 'erlang_erlang_ls_log_level')
11
12     let l:command = '%e'
13
14     if !empty(l:log_dir)
15         let l:command .= ' --log-dir=' . ale#Escape(l:log_dir)
16     endif
17
18     let l:command .= ' --log-level=' . ale#Escape(l:log_level)
19
20     return l:command
21 endfunction
22
23 function! s:FindProjectRoot(buffer) abort
24     let l:markers = [
25     \   '_checkouts/',
26     \   '_build/',
27     \   'deps/',
28     \   'erlang_ls.config',
29     \   'rebar.lock',
30     \   'erlang.mk',
31     \]
32
33     " This is a way to find Erlang/OTP root (the one that is managed
34     " by kerl or asdf).  Useful if :ALEGoToDefinition takes us there.
35     let l:markers += ['.kerl_config']
36
37     for l:marker in l:markers
38         let l:path = l:marker[-1:] is# '/'
39         \   ? ale#path#FindNearestDirectory(a:buffer, l:marker)
40         \   : ale#path#FindNearestFile(a:buffer, l:marker)
41
42         if !empty(l:path)
43             return ale#path#Dirname(l:path)
44         endif
45     endfor
46
47     return ''
48 endfunction
49
50 call ale#linter#Define('erlang', {
51 \   'name': 'erlang_ls',
52 \   'executable': {b -> ale#Var(b, 'erlang_erlang_ls_executable')},
53 \   'command': function('s:GetCommand'),
54 \   'lsp': 'stdio',
55 \   'project_root': function('s:FindProjectRoot'),
56 \   'aliases': ['erlang-ls'],
57 \})