For VS Code, I use rust-analyzer
to handle syntax highlighting and flychecking. But if I don't add type annotations to declarations in the code, rust-analyzer
shows the missing type annotations in the file without actually inserting it in the code. Is there a way to turn this off?
I prefer to add my own type annotations and I'm more likely to forget that if rust-analyzer
shows me the missing annotations, and sometimes they're in the way as I have auto formatting on save set, and this formatting breaks up the lines correctly. With rust-analyzers
's type annotation help, some lines become too long to fit on my screen.
In the picture below, it's the grey text I'm referring to. I would like it gone.
CodePudding user response:
In Visual Studio Code you can easily do this.
- Open the settings page (Ctrl ,)
- Search for "rust-analyzer inlay"
- Uncheck things you don't want
- In your case that would be "Parameter Hints" and "Type Hints"
If you're not using Visual Studio Code you'll need to manually edit the JSON config file of rust-analyzer (helpful link to the documentation). Basically
- Open the JSON config file in your favourite text editor
- Add a new property to the root of the JSON object like so:
{
"inlayHints": {
"typeHints": false,
"parameterHints": false
},
// further configuration
}