Skip to content

x/tools/gopls: show documentation when hovering on func token for function literal whose type is documented #76191

@Lslightly

Description

@Lslightly

Example:

filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error {
    ...
}

I'm always frustrated when I'm writing function body of a function literal passed as an argument of a call statement. When calling external libraries with callback arguments, I sometimes forget the meaning of the parameter, like err parameter of function literal whose type is the named type fs.WalkDirFunc, and I have to go to the documentation website, which is inconvenient. Besides, sometimes I want to see the documentation of fs.WalkDirFunc. I have to first jump to the definition of filepath.WalkDir, then jump to the type definition of fs.WalkDirFunc.

The type of the function literal can be decided if it's passed as an argument and the argument type is fs.WalkDirFunc or the declared type is a defined type, like var fn fs.WalkDirFunc

Describe the solution you'd like
A clear and concise description of what you want to happen.

Show documentation of function type definition when hovering over func token of the function literal if the function literal has no function name and the type of the function literal can be decided as a named type.

For example, documentation of fs.WalkDirFunc will be shown when hover over func token in the above example.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Concat documentation of named types of arguments after the documentation of named function.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    goplsIssues related to the Go language server, gopls.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions