Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support Rust #256

Open
XVilka opened this issue Oct 9, 2022 · 4 comments
Open

Feature request: support Rust #256

XVilka opened this issue Oct 9, 2022 · 4 comments
Labels
needs: contribution Contributions are welcome

Comments

@XVilka
Copy link

XVilka commented Oct 9, 2022

Supporting messages from:

  • cargo
  • clippy
@mfussenegger mfussenegger added the needs: contribution Contributions are welcome label Oct 16, 2022
@benmanone
Copy link

just added a pull request for support for rust_analyzer

@qithron
Copy link

qithron commented Mar 2, 2023

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"

@alexmozaidze
Copy link

alexmozaidze commented Apr 27, 2023

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

@juniorsaldanha
Copy link
Contributor

Anyone working on cargo implementation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: contribution Contributions are welcome
Projects
None yet
Development

No branches or pull requests

6 participants