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 support for folding comment regions #51364

Closed
codyoss opened this issue Feb 25, 2022 · 5 comments
Closed

x/tools/gopls: add support for folding comment regions #51364

codyoss opened this issue Feb 25, 2022 · 5 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@codyoss
Copy link
Member

codyoss commented Feb 25, 2022

gopls version

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

What did you do?

Wrote a program with comment regions

package foo

//region foomethods

func Bar() string {
	return "Bar"
}

func Baz() string {
	return Baz""
}

//endregion foomethods

What did you expect to see?

I expected to be able to collapse the regions
Screen Shot 2022-02-25 at 9 16 38 AM

Screen Shot 2022-02-25 at 9 17 30 AM

What did you see instead?

No folding support by the language server.

Screen Shot 2022-02-25 at 9 18 29 AM

Editor and settings

To get the desired effect I was able to switch editor.foldingStrategy = "indentation". This does not seem ideal though as I believe this bypasses any special folding that the language server provides.

@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 Feb 25, 2022
@gopherbot gopherbot added this to the Unreleased milestone Feb 25, 2022
@findleyr
Copy link
Contributor

findleyr commented Mar 3, 2022

Thank you for the issue.

Is 'region' supported by other Go tools? Do you have a reference for how 'region' should behave?

Go source code is consumed by many tools, including other editors and pkg.go.dev. Adding comment annotations to control the behavior of any one tool is generally discouraged.

@findleyr findleyr added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 3, 2022
@codyoss
Copy link
Member Author

codyoss commented Mar 4, 2022

Is 'region' supported by other Go tools?

No. But I don't think it makes sense in the context of other Go tooling. This is just an IDE code organization feature.

Do you have a reference for how 'region' should behave?

It should behave just like folding an if statement or a function. Here is VS Codes official docs and the syntax other language servers support for this feature: folding

Go source code is consumed by many tools, including other editors and pkg.go.dev.

These comments are not attached to any symbols so they would not show up in godoc.

Adding comment annotations to control the behavior of any one tool is generally discouraged.

I hear you, this is really one an editor feature. But I would say it is a common feature. So it really only makes context in of a language server.

@codyoss
Copy link
Member Author

codyoss commented Mar 4, 2022

Related, with maybe some extra info: microsoft/vscode#91140

@hyangah
Copy link
Contributor

hyangah commented Mar 4, 2022

Duplicate of golang/vscode-go#134

@hyangah hyangah marked this as a duplicate of golang/vscode-go#134 Mar 4, 2022
@findleyr
Copy link
Contributor

findleyr commented Mar 4, 2022

Closing in favor of the vscode issue.

@findleyr findleyr closed this as completed Mar 4, 2022
@golang golang locked and limited conversation to collaborators Mar 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants