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: utilize placeholders in var! postfix suggestion #59689

Closed
caichuanwang opened this issue Apr 3, 2023 · 5 comments
Closed

x/tools/gopls: utilize placeholders in var! postfix suggestion #59689

caichuanwang opened this issue Apr 3, 2023 · 5 comments
Labels
FeatureRequest gopls/completion Issues related to auto-completion in gopls. gopls Issues related to the Go language server, gopls.
Milestone

Comments

@caichuanwang
Copy link

Is your feature request related to a problem? Please describe.
I'm always frustrated when I use [var!] to automatically fill in a variable, the cursor is always not selected by default. I need to move the cursor to the variables one by one instead of using [tab] to quickly edit the name of the variable

Describe the solution you'd like
Directly use [tab] to quickly edit the name of the variable

Describe alternatives you've considered
no ,There is no alternative but to move the cursors one by one

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

@hyangah
Copy link
Contributor

hyangah commented Apr 10, 2023

@caichuanwang Can you please share a screenshot or an example to demonstrate the issue? That will help us understand the issue. And, please share your vscode settings.json. Thanks!

@hyangah hyangah added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 10, 2023
@caichuanwang
Copy link
Author

this is my setting.json about go in vs code
"go.lintTool": "golangci-lint", "go.lintFlags": ["--fast"], "editor.fontFamily": "JetBrains Mono,FiraCode-Retina,Menlo, Monaco, 'Courier New', monospace", "editor.fontSize": 14, "go.inlayHints.constantValues": true, "better-comments.highlightPlainText": true
now is

vscode.mp4

but i want that like goland

goland.mp4

I think this is a feature,not bug

@hyangah
Copy link
Contributor

hyangah commented Apr 18, 2023

Thanks for the example and screenshot, @caichuanwang
I also think that utilizing the snippet position placeholders when the suggested vars are fake is better.
Moving this to gopls issue tracker.

Related code:
https://github.com/golang/tools/blob/60d9c064d4efe2a5b76fa64ecfc012671ee8f231/gopls/internal/lsp/source/completion/postfix_snippets.go#L306-L307
https://github.com/golang/tools/blob/60d9c064d4efe2a5b76fa64ecfc012671ee8f231/gopls/internal/lsp/source/completion/postfix_snippets.go#L165-L166

@hyangah hyangah changed the title After using var! to automatically fill variables, select the filled variables with the cursor for editing x/tools/gopls: utilize placeholders in var! postfix suggestion Apr 18, 2023
@hyangah hyangah removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 18, 2023
@gopherbot gopherbot added this to the Unreleased milestone Apr 18, 2023
@hyangah hyangah transferred this issue from golang/vscode-go Apr 18, 2023
@hyangah hyangah added gopls/completion Issues related to auto-completion in gopls. FeatureRequest gopls Issues related to the Go language server, gopls. labels Apr 18, 2023
@jan-xyz
Copy link

jan-xyz commented Aug 26, 2023

I'd like to try my luck with this! I already had a look at the code. What's the best approach? Does it make sense to migrate the postfix snippets also to snippet.Builder, or should we try to make it work with the template strings?

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/541277 mentions this issue: gopls/internal/lsp/source/completion: support more postfix completion for map and slice (len, for, forr)

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.
Projects
None yet
5 participants