]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/scala/metals.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 / scala / metals.vim
1 " Author: Jeffrey Lau - https://github.com/zoonfafer
2 " Description: Metals Language Server for Scala https://scalameta.org/metals/
3
4 call ale#Set('scala_metals_executable', 'metals')
5 call ale#Set('scala_metals_project_root', '')
6
7 function! ale_linters#scala#metals#GetProjectRoot(buffer) abort
8     let l:project_root = ale#Var(a:buffer, 'scala_metals_project_root')
9
10     if !empty(l:project_root)
11         return l:project_root
12     endif
13
14     let l:potential_roots = [
15     \   'build.sc',
16     \   'build.sbt',
17     \   '.bloop',
18     \   '.metals',
19     \]
20
21     for l:root in l:potential_roots
22         let l:project_root = ale#path#ResolveLocalPath(
23         \   a:buffer,
24         \   l:root,
25         \   ''
26         \)
27
28         if !empty(l:project_root)
29             return fnamemodify(
30             \   l:project_root,
31             \   ':h',
32             \)
33         endif
34     endfor
35
36     return ''
37 endfunction
38
39 function! ale_linters#scala#metals#GetCommand(buffer) abort
40     return '%e' . ale#Pad('stdio')
41 endfunction
42
43 call ale#linter#Define('scala', {
44 \   'name': 'metals',
45 \   'lsp': 'stdio',
46 \   'language': 'scala',
47 \   'executable': {b -> ale#Var(b, 'scala_metals_executable')},
48 \   'command': function('ale_linters#scala#metals#GetCommand'),
49 \   'project_root': function('ale_linters#scala#metals#GetProjectRoot'),
50 \})