diff options
author | Felix Maurer <felix@felix-maurer.de> | 2022-03-23 02:56:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-23 10:56:29 +0900 |
commit | 80dcd648d389965603246c2c5a4554e3e4aa184c (patch) | |
tree | c6a226966fd879df41360632103f366fef2d444e /ale_linters | |
parent | 5c7019f394588bdc29d7573f5063198c2803dfe4 (diff) | |
download | ale-80dcd648d389965603246c2c5a4554e3e4aa184c.zip |
rust-analyzer for non-Cargo projects (#4118)
* rust-analyzer in non-cargo projects
rust-analyzer can also be used in non-cargo projects. This requires a
rust-project.json file in the project root [1].
Make the rust-analyzer linter search for a rust-project.json file if no
Cargo.toml file could be found.
[1]: https://rust-analyzer.github.io/manual.html#non-cargo-based-projects
* Document rust-analyzer without cargo
* Test rust-analyzer with non-cargo projects
Change the other rust tests to match the new directory structure of the
test files.
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/rust/analyzer.vim | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/ale_linters/rust/analyzer.vim b/ale_linters/rust/analyzer.vim index 77d946f7..3ead3871 100644 --- a/ale_linters/rust/analyzer.vim +++ b/ale_linters/rust/analyzer.vim @@ -9,9 +9,21 @@ function! ale_linters#rust#analyzer#GetCommand(buffer) abort endfunction function! ale_linters#rust#analyzer#GetProjectRoot(buffer) abort + " Try to find nearest Cargo.toml for cargo projects let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') - return !empty(l:cargo_file) ? fnamemodify(l:cargo_file, ':h') : '' + if !empty(l:cargo_file) + return fnamemodify(l:cargo_file, ':h') + endif + + " Try to find nearest rust-project.json for non-cargo projects + let l:rust_project = ale#path#FindNearestFile(a:buffer, 'rust-project.json') + + if !empty(l:rust_project) + return fnamemodify(l:rust_project, ':h') + endif + + return '' endfunction call ale#linter#Define('rust', { |