summaryrefslogtreecommitdiff
path: root/ale_linters/rust/analyzer.vim
diff options
context:
space:
mode:
authorJon Gjengset <jon@thesquareplanet.com>2019-10-16 11:34:06 -0400
committerJon Gjengset <jon@thesquareplanet.com>2019-10-16 11:34:16 -0400
commitf5c289dce68f1592281b5d70539df91d4b3d2821 (patch)
tree186a245ea37232eed48c3654491ac5122a4e4401 /ale_linters/rust/analyzer.vim
parent7c5825ecbc166d71976d01213e42723128d933e7 (diff)
downloadale-f5c289dce68f1592281b5d70539df91d4b3d2821.zip
Add support for rust-analyzer
Fixes #2832
Diffstat (limited to 'ale_linters/rust/analyzer.vim')
-rw-r--r--ale_linters/rust/analyzer.vim24
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'),
+\})