diff options
author | Jon Gjengset <jon@thesquareplanet.com> | 2019-10-16 11:34:06 -0400 |
---|---|---|
committer | Jon Gjengset <jon@thesquareplanet.com> | 2019-10-16 11:34:16 -0400 |
commit | f5c289dce68f1592281b5d70539df91d4b3d2821 (patch) | |
tree | 186a245ea37232eed48c3654491ac5122a4e4401 /ale_linters/rust | |
parent | 7c5825ecbc166d71976d01213e42723128d933e7 (diff) | |
download | ale-f5c289dce68f1592281b5d70539df91d4b3d2821.zip |
Add support for rust-analyzer
Fixes #2832
Diffstat (limited to 'ale_linters/rust')
-rw-r--r-- | ale_linters/rust/analyzer.vim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ale_linters/rust/analyzer.vim b/ale_linters/rust/analyzer.vim new file mode 100644 index 00000000..54a7cb1c --- /dev/null +++ b/ale_linters/rust/analyzer.vim @@ -0,0 +1,24 @@ +" Author: Jon Gjengset <jon@thesquareplanet.com> +" Description: The next generation language server for Rust + +call ale#Set('rust_analyzer_executable', 'ra_lsp_server') +call ale#Set('rust_analyzer_config', {}) + +function! ale_linters#rust#analyzer#GetCommand(buffer) abort + return '%e' +endfunction + +function! ale_linters#rust#analyzer#GetProjectRoot(buffer) abort + let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') + + return !empty(l:cargo_file) ? fnamemodify(l:cargo_file, ':h') : '' +endfunction + +call ale#linter#Define('rust', { +\ 'name': 'rust-analyzer', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'rust_analyzer_config')}, +\ 'executable': {b -> ale#Var(b, 'rust_analyzer_executable')}, +\ 'command': function('ale_linters#rust#analyzer#GetCommand'), +\ 'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'), +\}) |