nvim-lint
nvim-lint copied to clipboard
Feature request: support Rust
Supporting messages from:
-
cargo -
clippy
just added a pull request for support for rust_analyzer
I use format from rust-lang/rust.vim. Support both cargo and clippy. But messages from cargo check need a filter, because contain messages from other files too.
local MOD = require('lint')
MOD.linters_by_ft = {
rust = {'rust_lint'},
}
-- rust: rust_lint
local format = '%E%f:%l:%c: %\\d%#:%\\d%# %.%\\{-}'
.. 'error:%.%\\{-} %m,%W%f:%l:%c: %\\d%#:%\\d%# %.%\\{-}'
.. 'warning:%.%\\{-} %m,%C%f:%l %m,%-G,%-G'
.. 'error: aborting %.%#,%-G'
.. 'error: Could not compile %.%#,%E'
.. 'error: %m,%Eerror[E%n]: %m,%-G'
.. 'warning: the option `Z` is unstable %.%#,%W'
.. 'warning: %m,%Inote: %m,%C %#--> %f:%l:%c'
MOD.linters.rust_lint = {
cmd = 'rust-vim-lint',
stdin = false,
append_fname = true,
args = {},
stream = 'both',
ignore_exitcode = false,
env = nil,
parser = require('lint.parser').from_errorformat(format)
}
And rust-vim-lint is a wrapper to support both clippy-driver and cargo check.
#!/usr/bin/env sh
test "$1" || exit 1
d=$(dirname "$(realpath "$1")")
while test "$(echo "$d" | grep -o '/' | wc -l)" -ge 1
do
test -f "$d/Cargo.toml" && {
cd "$d" || exit 1
exec cargo check
}
d=$(echo "$d" | sed s/'\/[^\/]*$'//)
done
exec clippy-driver "$1"
rust_analyzer is really slow, having linting with cargo would be greatly appreciated
Anyone working on cargo implementation?