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

Disable deduced types or make it on-hover only #3267

Closed
shamatar opened this issue Feb 22, 2020 · 12 comments · Fixed by #3269
Closed

Disable deduced types or make it on-hover only #3267

shamatar opened this issue Feb 22, 2020 · 12 comments · Fixed by #3269

Comments

@shamatar
Copy link

shamatar commented Feb 22, 2020

May be it’s a question of getting used to something, but by-default displayed type annotations after “let var” statements are verbose and make it difficult to edit the variable name (cursor jumps to the end on the type hint if it’s past the last symbol). There is no place in the documentation how to disable it, and extension settings do not give any hint.

@shamatar shamatar changed the title Disable deduced types or make Disable deduced types or make it on-hover only Feb 22, 2020
@SomeoneToIgnore
Copy link
Contributor

I think you're looking for the display inlay hints setting.
Surprisingly, there's no documentation about that indeed, I'll add some shortly, thank you.

bors bot added a commit that referenced this issue Feb 22, 2020
3269: Add inlay hints documentation r=flodiebold a=SomeoneToIgnore

Closes #3267

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
@bors bors bot closed this as completed in 9999660 Feb 22, 2020
@bors bors bot closed this as completed in #3269 Feb 22, 2020
@matklad
Copy link
Member

matklad commented Feb 22, 2020

I'd also like to expand a bit on our philosophy for default settings: in general, we prefer to enable all bells and whistles by default, because that helps with discoverability.

If a particular feature annoys you, it usually is straigforward to look at the docs for the way to disable it (if it is actually documented, oups :) )

OTOH, if you would love to use a feature, but do not know that it exists in the first place, you probably won't even try to find it in the docs.

I am contemplating (long-term) about having two presents for settings:

  • new user, where everything is enabled by default and is displaied via GUI elements
  • expert, where we keep everything accessible by a shortcut, but minize the amount of GUI elements.

@shamatar
Copy link
Author

@matklad Thank you for a response. The problem is while some “inlay” (maybe inline is more intuitive?) features are good such as parameter name hints, current implementation of type hints after “let x” statement provides very strange behavior when cursor jumps to the end of the type hint instead of the end of the variable name that makes a lot of distraction and visually misguiding.

@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Feb 24, 2020

Yes, unfortunately, this is the best solution we have currently for the type hints, the reasoning behind it is described in the documentation now (see the PR that closed this issue).

We have another issue for toggling the different categories of hints separately, hope this will help you when gets implemented.

@nbro
Copy link

nbro commented Jan 8, 2023

This issue should at least link to the documentation that describes how to disable these annoying type hints. It seems you can do it by going to the VS Code Preferences, then Settings, then search for Whether to show inlay type hints for variables, then uncheck that box.

@timkofu
Copy link

timkofu commented Jan 28, 2023

In my case, I also unchecked Whether to show function parameter name inlay hints at the call site.

@randal923
Copy link

I also turned off Enables the inlay hints in the editor.

@hraftery
Copy link

Turning off Inlay Hints > Parameter Hints and Inlay Hints > Type Hints did the trick for me. Otherwise the jumpy x-alignment was too distracting as I tried to read and edit what I've just written.

But I'd like to call attention to the second part of the original issue: "or make it on-hover only". I'd hate to actually lose these hints, which are really valuable when you want them. Is there a way to display them without the associated cursor movement and text x-direction movement issues?

I think the existing hover text might actually be sufficient - hovering over the function shows the function parameter names, and hovering over a variable shows its type. So I think nothing is lost, but I'm new here so I hope I haven't undone the great benefits of this plugin.

@Wxh16144
Copy link

@hraftery As far as I know this plugin is fully supported, here is my configuration:

// ...
"rust-analyzer.inlayHints.typeHints.enable": false, // 关闭类型提示
"rust-analyzer.inlayHints.parameterHints.enable": false, // 关闭参数提示
//..

@airstrike
Copy link

I wish toggling these inlay hints on/off was available in the command palette. They're useful every now and then, but often feel like clutter so I keep toggling them in the settings

@matklad
Copy link
Member

matklad commented Jun 27, 2023

https://code.visualstudio.com/updates/v1_67#_toggle-inlay-hints might help

@mrcampbell
Copy link

mrcampbell commented Mar 6, 2024

Perhaps related: the "7 Implementations" is from "Code Lens", and the VS Code Setting JSON key is "rust-analyzer.lens.enable": false, to disable it.

While valuable, it's provided in the popup window on hover, so it's not necessary to have it floating between your lines of code at all times

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants