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

UI: support inlay hints (parameter hints) #1631

Closed
birraasmile opened this issue Jul 20, 2021 · 24 comments
Closed

UI: support inlay hints (parameter hints) #1631

birraasmile opened this issue Jul 20, 2021 · 24 comments

Comments

@birraasmile
Copy link

Hello vscode-go team,
Can you please try to make the vscode-go extension support parameter name hints in the upcoming version ? :)

Example of similar support at the moment is the extension https://marketplace.visualstudio.com/items?itemName=DominicVonk.parameter-hints which started supporting parameter name hints with TypeScript 4.4.

It would be perfect to see have this feature available through vscode-go extension if the editor has API for it. thanks

@gopherbot gopherbot added this to the Untriaged milestone Jul 20, 2021
@stamblerre
Copy link
Contributor

The language server protocol does not yet have support for this behavior -- see microsoft/language-server-protocol#956.

@hyangah
Copy link
Contributor

hyangah commented Jan 5, 2022

The upstream issue (LSP support) is waiting for the inlayHints VS Code API to be finalized (microsoft/vscode#16221).

@hyangah hyangah changed the title Parameter name hints for vscode-go - if the editor has API for it. UI: support inlay hints (parameter hints) Jan 5, 2022
@pepsighan
Copy link

The VS Code API has been finalized: microsoft/vscode#16221 (comment).

@Frederick888
Copy link

Is there an issue already at https://github.com/golang/go/issues?

@hyangah
Copy link
Contributor

hyangah commented Feb 25, 2022

As soon as LSP spec is finalized, we can start working on adding that to gopls.

@li1234yun
Copy link

li1234yun commented Mar 4, 2022

@hyangah Hello, VSCode 1.65 the inlay hints api was finalized :-)

VSCode 1.65 Inlay Hints Release Note

@Med-H
Copy link

Med-H commented May 3, 2022

any news on this feature?

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/410132 mentions this issue: tools/internal: support textDocument/inlayHint

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/411094 mentions this issue: tools/internal: support textDocument/inlayHint

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/410974 mentions this issue: internal/lsp: add inlay hints to server capabilities

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/411100 mentions this issue: internal/lsp: add inlay hints for variable types

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/411102 mentions this issue: internal/lsp: add inlay hints for composite literals

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/411101 mentions this issue: internal/lsp: add inlay hints for constant values

@jamalc
Copy link
Contributor

jamalc commented Jun 10, 2022

Here is the initial set of inlay hints we plan to support, with configuration to enable or disable them independently. Let us know if there are additional config options or hint types you would like us to consider.

Parameter Names

Will include configuration for showing hints for only literals and suppressing hints when an argument matches the parameter name.
Screen Shot 2022-06-10 at 1 30 04 PM

Constant Values

Similar to Enum Member Values for TypeScript inlay hints. Enables hints for sequential values declared using the iota constant generator and implicit repetition.
Screen Shot 2022-06-10 at 1 30 51 PM

Variable Types

Screen Shot 2022-06-10 at 1 30 21 PM

Composite Literal Field Names

Screen Shot 2022-06-10 at 1 42 57 PM

Composite Literal Types

Screen Shot 2022-06-10 at 1 32 15 PM

gopherbot pushed a commit to golang/tools that referenced this issue Jun 10, 2022
This change implements support for textDocument/inlayHint and
adds inlay hints for parameter names.

For golang/go#52343.
For golang/vscode-go#1631.

Change-Id: I3f989838b86cef4fd2b4076cb6340010fff7c24c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/411094
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopherbot pushed a commit to golang/tools that referenced this issue Jun 10, 2022
For golang/go#52343.
For golang/vscode-go#1631.

Change-Id: I94a1b3c389d8bfaa48754e28a52ef76c29eb6ead
Reviewed-on: https://go-review.googlesource.com/c/tools/+/411100
Run-TryBot: Jamal Carvalho <jamal@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
gopherbot pushed a commit to golang/tools that referenced this issue Jun 10, 2022
For golang/go#52343.
For golang/vscode-go#1631.

Change-Id: Iaef0beab2837502f6428767f457d1da21848fcb6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/411101
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
gopherbot pushed a commit to golang/tools that referenced this issue Jun 10, 2022
For golang/go#52343.
For golang/vscode-go#1631.

Change-Id: I8fba5ddf0bd25ba0fc20f3305ce13868f426087c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/411102
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
@hyangah
Copy link
Contributor

hyangah commented Jun 14, 2022

From @zombiezen:

The Rust language server has a nice subtle touch where if the parameter name matches the argument variable given, it skips showing the inlay.

It looks like Javascript/Typescript have similars, e.g. javascript.inlayHints.parameterNames.suppressWhenArgumentMatchesName

@hyangah hyangah removed this from the vscode-go/unplanned milestone Jun 14, 2022
@hyangah hyangah added this to the v0.35.0 milestone Jun 14, 2022
@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/413678 mentions this issue: vscode-go: add inlay hint settings to extension config

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/413679 mentions this issue: tools/goplssetting: omit inlay hints from gopls settings

gopherbot pushed a commit that referenced this issue Jun 24, 2022
Users can configure inlay hints through the go config.
Omitting these settings to prevent duplicate values.

For #1631.

Change-Id: I4ce10154210b1dc4ba34734a3aa3644b22349134
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/413679
TryBot-Result: kokoro <noreply+kokoro@google.com>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
gopherbot pushed a commit that referenced this issue Jun 28, 2022
Adding the inlay hint settings to the go configuration
allows for toggling inlay hints from settings.json or
the settings UI.

For #1631.

Change-Id: Iccf2ff3db89d195f694883403d4a25160d66e7ff
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/413678
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
@inliquid
Copy link

inliquid commented Jul 7, 2022

@hyangah I saw a release notes for support of inlay hints, but at least in my case that seems to not work:
изображение

Also nothing changed in IDE.

I always take gopls from @master if that matters.

@rammanokar
Copy link

Its working.. Awesome Work, thanks team. 👏👏👏 @hyangah @jamalc 👏👏👏

image

@n-r-w
Copy link

n-r-w commented Jul 8, 2022

I saw a release notes for support of inlay hints, but at least in my case that seems to not work

its working
image

@inliquid
Copy link

inliquid commented Jul 8, 2022

@n-r-w that's interesting, these config params work, however, according to https://github.com/golang/vscode-go/blob/master/docs/settings.md configuration should be done in general go.*, section, not gopls.*.

@jamalc
Copy link
Contributor

jamalc commented Jul 11, 2022

The go.* params work in vscode-go nightly and configuration is available in the UI at Go > Inlay Hints.

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/417295 mentions this issue: package.json: add markdown descriptions to inlay hints config

@hyangah
Copy link
Contributor

hyangah commented Jul 19, 2022

v0.35.0 released today has dedicated settings for inlay hints. Please use go.inlayHints.* settings or use the VSCode settings UI instead of "gopls": { "hints": ... }.

https://twitter.com/golang/status/1549106172870987776

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

No branches or pull requests