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: provide useful snippets as completion suggestions for language keywords #65219

Open
hyangah opened this issue Jan 22, 2024 · 0 comments
Labels
FeatureRequest gopls/completion Issues related to auto-completion in gopls. gopls Issues related to the Go language server, gopls. 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

Comments

@hyangah
Copy link
Contributor

hyangah commented Jan 22, 2024

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?

@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 Jan 22, 2024
@gopherbot gopherbot added this to the Unreleased milestone Jan 22, 2024
@hyangah hyangah added FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jan 22, 2024
@suzmue suzmue modified the milestones: Unreleased, gopls/backlog Jan 24, 2024
@suzmue suzmue added the gopls/completion Issues related to auto-completion in gopls. label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest gopls/completion Issues related to auto-completion in gopls. gopls Issues related to the Go language server, gopls. 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.
Projects
None yet
Development

No branches or pull requests

3 participants