Skip to content

x/tools/gopls: provide useful snippets as completion suggestions for language keywords  #65219

Description

@hyangah

I always wondered what is supplying func as a completion suggestion after typing func
which I rarely end up selecting. Looking at golang/vscode-go#3144,
I finally bothered to check it, and obviously, it was gopls.

[Trace - 16:54:46.674 PM] Received response 'textDocument/completion - (260)' in 81ms.
Result: {"isIncomplete":true,"items":[
{"label":"func","kind":14,"documentation":{"kind":"markdown","value":""},"preselect":true,"sortText":"00000","filterText":"func","insertTextFormat":2,"textEdit":{"range":{"start":{"line":16,"character":0},"end":{"line":16,"character":4}},"newText":"func"}},
{"label":"functional","kind":9,"detail":"\"github.com/vmware/govmomi/test/functional\"","documentation":{"kind":"markdown","value":""},"sortText":"00001","filterText":"functional","insertTextFormat":2,"textEdit":{"range":{"start":{"line":16,"character":0},"end":{"line":16,"character":4}},"newText":"functional"},"additionalTextEdits":[{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":7}},"newText":"(\n\t"} ...

If clients can handle snippets, and gopls is relatively sure that the user is about to type func F() {} (e.g. there is no following character in the same line, etc), is it better to provide longer snippets?

Similarly, I type c, gopls suggests const as the first candidate. If that's what I really intended, couldn't gopls even go further and place a space and move my cursor to define a const var rather than just stopping at const and letting me type space after accepting the keyword?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/completionIssues related to auto-completion in gopls.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions