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

Merge commit '294584081929424aec883f90c7d6515b3743358d' as '.vim/bundle/vim-lsp-ale'
[etc/vim.git] / .vim / bundle / ale / ale_linters / rust / analyzer.vim
1 " Author: Jon Gjengset <jon@thesquareplanet.com>
2 " Description: The next generation language server for Rust
3
4 call ale#Set('rust_analyzer_executable', 'rust-analyzer')
5 call ale#Set('rust_analyzer_config', {})
6
7 function! ale_linters#rust#analyzer#GetCommand(buffer) abort
8     return '%e'
9 endfunction
10
11 function! ale_linters#rust#analyzer#GetProjectRoot(buffer) abort
12     " Try to find nearest Cargo.toml for cargo projects
13     let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')
14
15     if !empty(l:cargo_file)
16         return fnamemodify(l:cargo_file, ':h')
17     endif
18
19     " Try to find nearest rust-project.json for non-cargo projects
20     let l:rust_project = ale#path#FindNearestFile(a:buffer, 'rust-project.json')
21
22     if !empty(l:rust_project)
23         return fnamemodify(l:rust_project, ':h')
24     endif
25
26     return ''
27 endfunction
28
29 call ale#linter#Define('rust', {
30 \   'name': 'analyzer',
31 \   'aliases': ['rust_analyzer'],
32 \   'lsp': 'stdio',
33 \   'initialization_options': {b -> ale#Var(b, 'rust_analyzer_config')},
34 \   'executable': {b -> ale#Var(b, 'rust_analyzer_executable')},
35 \   'command': function('ale_linters#rust#analyzer#GetCommand'),
36 \   'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'),
37 \})