templ icon indicating copy to clipboard operation
templ copied to clipboard

[Feature request]: VS Code extension - enable / fix folding of templ elements

Open iacore opened this issue 6 months ago • 5 comments

Image

Saw https://github.com/templ-go/templ-vscode/pull/66, but it doesn't seem to be the case.

Folding works if the extension is disabled:

Image

iacore avatar Jul 01 '25 01:07 iacore

Sorry, can't reproduce. Not enough information in your issue to investigate further.

Image

a-h avatar Aug 05 '25 11:08 a-h

You can't fold the templ line. In Go, one can fold func.

iacore avatar Aug 10 '25 21:08 iacore

I researched this. According to the VS Code docs, disabling the LSP FoldingRangeProvider in server.go should force VS Code to use its default folding - https://code.visualstudio.com/api/references/vscode-api#languages.registerFoldingRangeProvider

// Remove the code folding so that the built-in code folding of the editor is used.
result.Capabilities.FoldingRangeProvider = false

However, the VS Code LSP client still attempts to register a folding provider.

There's some sort of VS Code configuration problem. It looks like the templ VS Code extension is doing everything OK, meaning that since the LSP doesn't provider folding, VS Code should use its default folding and the folding should be automatic based on the text mate grammar, or via the language-configuration.json file (you can add extra folding rules in there).

a-h avatar Aug 13 '25 07:08 a-h

Sorry that I don't understand this. Perhaps the VS Code LSP Typescript library is different from the VS Code API?

iacore avatar Aug 13 '25 11:08 iacore

Sorry. This comment was really a bit of a note for me, rather than instructions for you to do something.

It's a case of tracking down the issue in various VS Code settings and API options within the VS Code extension codebase, rather than user facing settings.

a-h avatar Aug 13 '25 12:08 a-h