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: support folding regions in vscode's #region comments #67398

Closed
TheDevMinerTV opened this issue May 15, 2024 · 5 comments
Closed
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@TheDevMinerTV
Copy link

gopls version

golang.org/x/tools/gopls v0.15.3

go env

doesn't apply

What did you do?

  1. Write a region comment in VSCode and the corresponding end region comment:
// #region Some code region
func whatever() {}
// #endregion
  1. Notice that these regions aren't collapsible

What did you see happen?

I wasn't able to collapse the regions are collapsible.

What did you expect to see?

The ability to collapse the code between those comments into a single line, like it works with the TypeScript LSP. This makes code easier to structure when having long functions (yes, I know this is not good code, but eh).

Editor and settings

VSCode 1.89.0
Go 1.22.2
vscode-go v0.41.4

Logs

No response

@TheDevMinerTV TheDevMinerTV added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels May 15, 2024
@gopherbot gopherbot added this to the Unreleased milestone May 15, 2024
@hyangah
Copy link
Contributor

hyangah commented May 16, 2024

This is a duplicate of golang/vscode-go#134
If you prefer vscode's folding, choose "editor.foldingStrategy": "indentation". This is not go style.

@TheDevMinerTV
Copy link
Author

TheDevMinerTV commented May 16, 2024

This breaks the folding of comments though:
before
after

@hyangah
Copy link
Contributor

hyangah commented May 17, 2024

There are folding provider extensions that support #region annotations and customization.
VS Code can merge folding ranges from multiple extensions. (as long as they don't collide)
Please give them a try. It's not Go style, so we think this is out of scope.

@TheDevMinerTV
Copy link
Author

Mind linking a plugin that does?

@adonovan
Copy link
Member

Mind linking a plugin that does?

https://marketplace.visualstudio.com/items?itemName=MohammadBaqer.better-folding

(Not an endorsement; I have not audited, tested, or run the code.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. 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