nvim-lint icon indicating copy to clipboard operation
nvim-lint copied to clipboard

Feature request: support Rust

Open XVilka opened this issue 3 years ago • 4 comments

Supporting messages from:

  • cargo
  • clippy

XVilka avatar Oct 09 '22 03:10 XVilka

just added a pull request for support for rust_analyzer

benmanone avatar Jan 27 '23 17:01 benmanone

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"

qithron avatar Mar 02 '23 16:03 qithron

rust_analyzer is really slow, having linting with cargo would be greatly appreciated

alexmozaidze avatar Apr 27 '23 01:04 alexmozaidze

Anyone working on cargo implementation?

juniorsaldanha avatar Apr 30 '24 04:04 juniorsaldanha