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

How do I temporarily show Clippy warnings? #12323

Open
vi opened this issue May 20, 2022 · 3 comments
Open

How do I temporarily show Clippy warnings? #12323

vi opened this issue May 20, 2022 · 3 comments
Labels
A-diagnostics diagnostics / error reporting C-feature Category: feature request

Comments

@vi
Copy link
Contributor

vi commented May 20, 2022

I know that I can edit settings to invoke cargo clippy instead of cargo check, save a file to trigger RA recheck, observe and fix Clippy issues in the project, then change settings back to use usual cargo check.

Is there (or should there be) a better, more user-friendly way of viewing Clippy diagnostics without modifying settings every time, also without opting in to Clippy notices permanently?

bors added a commit that referenced this issue May 20, 2022
…s-schievink

feat: Add "cargo clippy" task preset

We've had a couple of common presets in `Tasks: Run Task -> cargo -> cargo [check,build,test,...]` before. This PR adds `cargo clippy` to that list, which makes for a convenient way of occasionally running Clippy on your code without having to reconfigure the Check on Save command to clippy.

These presets all use the `cargo` task type that we provide, so diagnostics will show up in the editor. However, they don't go through the server-side parsing logic, so it's not possible to apply suggestions, and diagnostics are fairly "low-fidelity". It would be cool if we could somehow pass Cargo's JSON output through the LSP server and render it properly, for arbitrary tasks.

cc #12323
@jonas-schievink
Copy link
Contributor

I've added a cargo clippy task preset in #12326. Unfortunately that doesn't use the same diagnostics rendering logic as Check-on-Save does, so the result will be lower-quality diagnostics, but it's a start.

@jonas-schievink jonas-schievink added A-diagnostics diagnostics / error reporting C-feature Category: feature request labels May 20, 2022
@flodiebold
Copy link
Member

flodiebold commented May 20, 2022

IIRC there were some discussions (maybe even a PR) about adding a check-on-command, and it was rejected because task presets can be used instead. I think the diagnostic rendering (including quick fixes, potentially deduplication between the check and our own diagnostics, etc.), and the fact that task presets are VSCode specific, are arguments to build this into rust-analyzer properly though.

@Jesse-Bakker
Copy link
Contributor

Since version 3.17, LSP has support for pull-based diagnostic reporting. There is no built-in way to specify which diagnostics to report unfortunately, so it might need an extension to allow for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics diagnostics / error reporting C-feature Category: feature request
Projects
None yet
Development

No branches or pull requests

4 participants