Search code examples
vimvim-pluginlinter

Vim ALE processing an older version of the file I'm editing


I'm using VIM 8.1 with ALE, specifically the rust linter (basically just cargo). The problem is that the errors and warnings reported by ALE are from an older version of the current file. Editing and saving the file has no effect, nor does re-starting vim. I've tried :ALEReset and then :ALELint, but it just shows the same lints. Other tools (like cargo) use the files just fine, and there doesn't appear to be anything wrong with the file itself.

This is the output of :ALEInfo:

 ALEInfo
 Current Filetype: rust
Available Linters: ['cargo', 'rls', 'rustc']
  Enabled Linters: ['cargo', 'rustc']
 Suggested Fixers:
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'rustfmt' - Fix Rust files with Rustfmt.
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
 Linter Variables:

let g:ale_rust_cargo_avoid_whole_workspace = 1
let g:ale_rust_cargo_check_all_targets = 0
let g:ale_rust_cargo_check_examples = 0
let g:ale_rust_cargo_check_tests = 1
let g:ale_rust_cargo_clippy_options = ''
let g:ale_rust_cargo_default_feature_behavior = 'default'
let g:ale_rust_cargo_include_features = ''
let g:ale_rust_cargo_use_check = 1
let g:ale_rust_cargo_use_clippy = 0
let g:ale_rust_ignore_error_codes = []
let g:ale_rust_ignore_secondary_spans = 0
let g:ale_rust_rustc_options = '-Z no-codegen'

ALE is my only installed plugin.

How can I fix this and use my linter plugin again?


Solution

  • It turned out that this was not a VIM or ALE issue, it was a cargo issue. ALE used cargo check to check code without doing codegen (it's faster and leaves less artifacts), and while cargo build did not return any errors or warning, cargo check for some reason returned warning from an older version of the project (not just the file). This was fixed with cargo clean, and then running cargo build and cargo check again. Because I ran cargo clean, I no longer have a project that causes this behavior, so I can't really delve deeper to find out what was wrong with the project.