x/tools/gopls: support "go to implementation" (textDocument/implementation) for function types #56572
Labels
Documentation
FeatureRequest
gopls
Issues related to the Go language server, gopls.
help wanted
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
As of gopls v0.10.1, the go to implementation feature of the LSP supports finding all of the types which implement an interface via the "Go to Implementation" feature in VS Code and Neovim etc.
This is a feature request to add the same support for named function types, and anonymous functions.
Current behaviour
go_to_implementation_interface.mov
Go also allows you to define function types and also accept functions as a parameter. This is seen in the standard library, e.g. https://pkg.go.dev/net/http#HandlerFunc and https://pkg.go.dev/strings#IndexFunc but here's a simple example.
Any function that has the same signature implements that function type.
So, you can use it like this:
The current behaviour of
gopls
does not allow you to go to the implementation off
from within the function body of theTestFunctionType
function.go_to_implementation_function_current.mov
And this same behaviour is true of anonymous functions:
go_to_implementation_function_anon_current.mov
Expected behavior
It should be possible to go the functions which implement the signature, as per this example.
go_to_function_type_implementation.mov
I've also tested the same behaviour with my modified version of the
gopls
Language Server running with Neovim.Implementation
I've got an implementation of the functionality to contribute.
The text was updated successfully, but these errors were encountered: