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

x/tools/gopls: jump to definition on 'return' should go to the result parameter list #70462

Closed
findleyr opened this issue Nov 20, 2024 · 10 comments
Assignees
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. help wanted Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Member

Frequently, when I'm looking at a return statement, I want to jump to the function signature.

In the category of "more LSP operations should work, more of the time", we could make jump to definition on a return statement go to the result parameter list.

@findleyr findleyr added this to the gopls/backlog milestone Nov 20, 2024
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Nov 20, 2024
@mateusz834
Copy link
Member

This would be also nice for break and continue, maybe goto, but not realy needed, because we can always go to definition of the label (it is required).

@findleyr
Copy link
Member Author

@mateusz834 we can do that too. I think whenever there is an obvious possible result for an LSP operation at a position, we should return it. It is a good UX when more operations work, more of the time.

@xzbdmw
Copy link

xzbdmw commented Nov 24, 2024

How about make hover works for return to show function signature.

@findleyr
Copy link
Member Author

How about make hover works for return to show function signature.

That's a great idea, too. Hover is probably more useful than definition, actually, but we can do both.

@findleyr
Copy link
Member Author

Hmm, although I do find that hover to be distracting in some editors. In my editor, I make it a manual operation, bound to a keystroke. I wonder if we should be cautious about popping up hover dialogs over everything.

@xzbdmw
Copy link

xzbdmw commented Nov 25, 2024

In fact, gopls is already conservative in hover -- rust-analyzer shows definition for every keyword.
Users are able to configure a debounce for hover request, so this should not be a big problem.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/636855 mentions this issue: gopls/internal/golang: definition support return statements

gopherbot pushed a commit to golang/tools that referenced this issue Dec 17, 2024
Enables you to use the definition operation on a return token
and brings you to the return parameters.

Updates golang/go#70462

Change-Id: I080ff37aad5ac1498e320429fad6dd4b043f02c8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/636855
Auto-Submit: Madeline Kalil <mkalil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
@findleyr findleyr assigned findleyr and unassigned findleyr Dec 17, 2024
@madelinekalil
Copy link

Finished "jump to definition" for return statements, will work on break/goto/continue next

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/637476 mentions this issue: gopls/internal/golang: hover support return statements

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/637818 mentions this issue: gopls/internal/golang: definition support break and goto statements

gopherbot pushed a commit to golang/tools that referenced this issue Dec 23, 2024
Hovering over a return statement now reveals the result type of the function.

Updates golang/go#70462

Change-Id: Ib15c0b3db52311762f021a514c0db7bd71411eb3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/637476
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. help wanted Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants