summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2022-02-03 10:50:30 +0100
committercos <cos>2022-02-19 16:53:08 +0100
commit6822c4a42437e3b3d002247bf48e4159f062c3b2 (patch)
treeb71cc17a2d74655bd3896f5fff73eba50f815fdf
parent7a3567d3e4d71aa738b1b2061d7b1f09901fc2c4 (diff)
downloadale-6822c4a42437e3b3d002247bf48e4159f062c3b2.zip
wip: Attempt at making cargo working on whole project as documented
(Make cargo work on whole project as documented) According to `:help ale-integration-rust`, using cargo as a linter should check the entire project. It appears this was the case initially, but it broke somewhere along the way. Setting `filename` to the output in the handler and avoid filtering the spans on `file_name` goes a long way in restoring the intended behavior. However test cases fail, even after attempting to update them. Please see next commit.
-rw-r--r--ale_linters/rust/cargo.vim1
-rw-r--r--ale_linters/rust/rustc.vim4
-rw-r--r--autoload/ale/handlers/rust.vim7
-rw-r--r--doc/ale-rust.txt10
4 files changed, 21 insertions, 1 deletions
diff --git a/ale_linters/rust/cargo.vim b/ale_linters/rust/cargo.vim
index 37fd10a8..e5fe888d 100644
--- a/ale_linters/rust/cargo.vim
+++ b/ale_linters/rust/cargo.vim
@@ -12,6 +12,7 @@ call ale#Set('rust_cargo_include_features', '')
call ale#Set('rust_cargo_use_clippy', 0)
call ale#Set('rust_cargo_clippy_options', '')
call ale#Set('rust_cargo_target_dir', '')
+call ale#Set('rust_only_current_buffer', '0')
function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort
if ale#path#FindNearestFile(a:bufnr, 'Cargo.toml') isnot# ''
diff --git a/ale_linters/rust/rustc.vim b/ale_linters/rust/rustc.vim
index bc6431ba..c7a06cc7 100644
--- a/ale_linters/rust/rustc.vim
+++ b/ale_linters/rust/rustc.vim
@@ -2,6 +2,10 @@
" Description: rustc for rust files
call ale#Set('rust_rustc_options', '--emit=mir -o /dev/null')
+" FIXME Both cargo and rustc uses ale#handlers#rust#HandleRustErrors which
+" might or might not require this, depending on the fix for [#1570]
+" (https://github.com/dense-analysis/ale/issues/1570).
+" call ale#Set('rust_only_current_buffer', '0')
function! ale_linters#rust#rustc#RustcCommand(buffer) abort
" Try to guess the library search path. If the project is managed by cargo,
diff --git a/autoload/ale/handlers/rust.vim b/autoload/ale/handlers/rust.vim
index a7fac464..895c7878 100644
--- a/autoload/ale/handlers/rust.vim
+++ b/autoload/ale/handlers/rust.vim
@@ -49,7 +49,11 @@ function! ale#handlers#rust#HandleRustErrors(buffer, lines) abort
endif
for l:root_span in l:error.spans
- let l:span = s:FindSpan(a:buffer, l:root_span)
+ if ale#Var(a:buffer, 'rust_only_current_buffer')
+ let l:span = s:FindSpan(a:buffer, l:root_span)
+ else
+ let l:span = l:root_span
+ endif
if ale#Var(a:buffer, 'rust_ignore_secondary_spans') && !get(l:span, 'is_primary', 1)
continue
@@ -57,6 +61,7 @@ function! ale#handlers#rust#HandleRustErrors(buffer, lines) abort
if !empty(l:span)
let l:output_line = {
+ \ 'filename': l:span.file_name,
\ 'lnum': l:span.line_start,
\ 'end_lnum': l:span.line_end,
\ 'col': l:span.column_start,
diff --git a/doc/ale-rust.txt b/doc/ale-rust.txt
index 8e846844..c51273ab 100644
--- a/doc/ale-rust.txt
+++ b/doc/ale-rust.txt
@@ -40,6 +40,16 @@ Integration Information
Also note that rustc 1.18. or later is needed.
+===============================================================================
+TODO
+
+g:ale_rust_only_current_buffer *g:ale_rust_only_current_buffer*
+ *b:ale_rust_only_current_buffer*
+ Type: |Number|
+ Default: `0`
+
+ Option to restore buggy operation. (FIXME: The existance of this option
+ might or might not be desired.)
===============================================================================
analyzer *ale-rust-analyzer*