I am coding in Rust by using VS Code, but the variable that i’m not used shows a ugly wavy underline, i want to disable it and just make my unused variables being gray which seems like IntelliJ IDEA shows unused functions.
VS Code:
goland
I am coding in Rust by using VS Code, but the variable that i’m not used shows a ugly wavy underline, i want to disable it and just make my unused variables being gray which seems like IntelliJ IDEA shows unused functions.
VS Code:
goland
2
Answers
I don’t believe you can make the name grey, but you can avoid the squiggles by changing the settings. In settings.json of VS Code:
As shown in Chayim’s answer you can change change the warnings to hints, which have a more subtle visual cue. I’m not sure of a way to remove all underline-related visual cues. Like so:
As for highlighting it grey, the Rust Analyzer extension doesn’t provide any dedicated semantic token for unused things at the time of this writing (I checked using the
Developer: Inspect Editor Tokens and Scopes
command). Semantic highlighting has a mechanism for "modifiers". There isn’t yet a modifier for unused things, but there’s a feature-request for that here: SemanticTokensModifier: Addunused
token modifier #604. You can give that issue ticket a thumbs up to show support for it, and subscribe to it to get notified about discussion and progress. If/when it does get implemented, you’d then also have to wait for the Rust Analyzer extension to make use of the feature.