-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #2832
- Loading branch information
Showing
5 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'), | ||
\}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,11 @@ Integration Information | |
over cargo. rls implements the Language Server Protocol for incremental | ||
compilation of Rust code, and can check Rust files while you type. `rls` | ||
requires Rust files to contained in Cargo projects. | ||
3. analyzer -- If you have rust-analyzer installed, you might prefer using | ||
this linter over cargo and rls. rust-analyzer also implements the | ||
Language Server Protocol for incremental compilation of Rust code, and is | ||
the next iteration of rls. rust-analyzer, like rls, requires Rust files | ||
to contained in Cargo projects. | ||
4. rustfmt -- If you have `rustfmt` installed, you can use it as a fixer to | ||
consistently reformat your Rust code. | ||
|
||
|
@@ -190,6 +195,25 @@ g:ale_rust_rls_config *g:ale_rust_rls_config* | |
\ } | ||
=============================================================================== | ||
analyzer *ale-rust-analyzer* | ||
|
||
g:ale_rust_analyzer_executable *g:ale_rust_analyzer_executable* | ||
*b:ale_rust_analyzer_executable* | ||
Type: |String| | ||
Default: `'ra_lsp_server'` | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jonhoo
Author
Contributor
|
||
|
||
This variable can be modified to change the executable path for | ||
`rust-analyzer`. | ||
|
||
|
||
g:ale_rust_analyzer_config *g:ale_rust_analyzer_config* | ||
*b:ale_rust_analyzer_config* | ||
Type: |Dictionary| | ||
Default: `{}` | ||
|
||
Dictionary with configuration settings for rust-analyzer. | ||
|
||
=============================================================================== | ||
rustc *ale-rust-rustc* | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Before: | ||
call ale#assert#SetUpLinterTest('rust', 'analyzer') | ||
|
||
After: | ||
call ale#assert#TearDownLinterTest() | ||
|
||
Execute(The default executable path should be correct): | ||
AssertLinter 'analyzer', ale#Escape('ra_lsp_server') | ||
|
||
Execute(The project root should be detected correctly): | ||
AssertLSPProject '' | ||
|
||
call ale#test#SetFilename('rust-rls-project/test.rs') | ||
|
||
AssertLSPProject ale#path#Simplify(g:dir . '/rust-rls-project') | ||
|
||
Execute(Should accept configuration settings): | ||
AssertLSPConfig {} | ||
let b:ale_rust_analyzer_config = {'rust': {'clippy_preference': 'on'}} | ||
AssertLSPConfig {'rust': {'clippy_preference': 'on'}} |
I thought RA changed the binary name to
rust-analyzer
recently?