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: add missing comma before newline in composite literal #62145

Open
drice opened this issue Aug 18, 2023 · 4 comments
Open

x/tools/gopls: add missing comma before newline in composite literal #62145

drice opened this issue Aug 18, 2023 · 4 comments
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@drice
Copy link

drice commented Aug 18, 2023

Whenever it is detected that a comma is missing before a newline in a composite literal, is it possible to add it?

image

Past issues for vscode-go:

@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 Aug 18, 2023
@gopherbot gopherbot added this to the Unreleased milestone Aug 18, 2023
@k-jingyang
Copy link

Hello, I'd like this feature as well. If external contributors can work on this feature, let me give it a try. 😄

@k-jingyang
Copy link

After digging a little, it seems that the double quotes are coming from vscode's go language configuration.

https://github.com/microsoft/vscode/blob/main/extensions/go/language-configuration.json

If we use the complete from the LSP, the comma is generated (though the double quotes are not generated in this case)
with-complete

If we don't use complete, the comma will not be generated
without-complete

I'm new to the LSP spec. Seems like it does not support auto-filling characters without having a completion prompt. So, if we want to improve user experience, we could get the completion (textDocument/completion) to insert double quotes if the struct field is a string?

@findleyr
Copy link
Contributor

As @k-jingyang points out, the comma is populated by auto-completion.

Within the constraints of LSP we don't have the ability to always automatically add the comma, but we can add a quick-fix to do so. @drice would that be sufficient?

@findleyr findleyr added FeatureRequest Refactoring Issues related to refactoring tools labels Aug 21, 2023
@findleyr findleyr modified the milestones: Unreleased, gopls/unplanned Aug 21, 2023
@drice
Copy link
Author

drice commented Aug 22, 2023

@findleyr Yes, that would be sufficient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants