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: document code actions that gopls supports #54115

Open
findleyr opened this issue Jul 28, 2022 · 2 comments
Open

x/tools/gopls: document code actions that gopls supports #54115

findleyr opened this issue Jul 28, 2022 · 2 comments
Labels
Documentation gopls help wanted Tools
Milestone

Comments

@findleyr
Copy link
Contributor

findleyr commented Jul 28, 2022

From discussion on gophers slack: it would be nice if gopls documented supported code actions, similar to how it documents other parameterized features (such as inlay hints: https://github.com/golang/tools/blob/master/gopls/doc/inlayHints.md).

Supported code actions are provided part of the initialize handshake, but we could document more precisely what we support.

@findleyr findleyr added this to the gopls/later milestone Jul 28, 2022
@gopherbot gopherbot added Tools gopls labels Jul 28, 2022
@gopherbot gopherbot modified the milestones: gopls/later, Unreleased Jul 28, 2022
@advinsuryavanshi
Copy link

advinsuryavanshi commented Jul 29, 2022

can i work on this...?

@findleyr
Copy link
Contributor Author

findleyr commented Jul 29, 2022

@advinsuryavanshi yes, contributions are very welcome!

However, be warned that we may want more than just pure documentation here. As much as possible, we try to generate our documentation from the gopls source. This prevents duplication, and helps ensure that documentation doesn't go stale. It also makes it easier to compile our documentation into JSON that can be read by editors. You can see examples of this in x/tools/gopls/doc/generate.go.

I haven't thought too much about code actions, but we should try to do something similar, basing our documentation off of x/tools/internal/lsp/source.DefaultOptions().SupportedCodeActions. One way to enforce that we have documentation would be to change the type of SupportedCodeActions. For example:

	SupportedCodeActions map[FileKind]map[protocol.CodeActionKind]string // file kind -> action kind -> description

In the future we could also go further and try to refactor such that code actions are parameterized, similarly to inlay hints (see x/tools/internal/lsp/source.AllInlayHints), but I don't think it is wise to undertake that refactoring now.

CC @suzmue @jamalc who may have opinions, having just done this for inlay hints.

@findleyr findleyr modified the milestones: Unreleased, gopls/later Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation gopls help wanted Tools
Projects
None yet
Development

No branches or pull requests

3 participants