Open paultyng opened 4 years ago
Apologies as I'm not too familiar with the LSP spec. Would this allow collapsing/expanding blocks, e.g., resource blocks, etc? If so, pretty cool!
@amasover yep, exactly. I'd imagine the simplistic initial implementation will just be folding of root level blocks (resource, provider, data, variable, output, module, local, terraform, etc.).
@paultyng I have try with this, But not working.
#region test
variable "test" {
type = bool
default = true
}
#endregion
@PePoDev we haven't implemented region folding yet. When we do you'll see a PR and a line item in our changelog
Hi,
I'm also interested in region folding, any news in regards of this? ππ€
Hi @aleqsss,
Sorry, but there hasn't been any progress on this. We are currently planning our roadmap for the first quarter, and it's already full of other issues we need to address. So at this point, it's tough for me to say when we can work on folding ranges.
Understood, and thank you for the information!
Hello, is this feature implemented?
@garsiv1932 Sorry, but we haven't implemented region folding yet
Is it too difficult?
Hey @garsiv1932 , just to clarify region folding support was implemented in the Terraform VS Code extension in https://github.com/hashicorp/vscode-terraform/pull/924, so if you do want to use them now we do support them. If you use another editor, that has not been planned yet.
Hey @garsiv1932 , just to clarify region folding support was implemented in the Terraform VS Code extension in hashicorp/vscode-terraform#924, so if you do want to use them now we do support them. If you use another editor, that has not been planned yet.
And how is the syntax, because i tried to put # regiion and #endRegion and didnt work.
Can You post the link of the vscode plugin too, only yo clarify if i AM using the dame one.
You can find our extension in the VS Code Marketplace or in the VS Code Extensions bar by typing 'hashicorp'.
The syntax is #region
and #endregion
:
https://github.com/hashicorp/terraform-ls/assets/272569/76881b3d-a5af-45bc-a196-28001088d5cf
I had a conflict on my extensions, is working right now.
The syntax is
#region
and#endregion
:
Sorry for nitpicking, but why are version with whitespace # region
and # endregion
not supported?
The format you mentioned is working fine though:
The syntax is
#region
and#endregion
:Sorry for nitpicking, but why are version with whitespace
# region
and# endregion
not supported?
@artemudovyk Is this still a problem for you? It seems to be working for me
@artemudovyk Is this still a problem for you? It seems to be working for me
Yeah, it's still the same for me.
Yeah, it's still the same for me.
I see the difference now. I was using v0.2.5 of 4ops.terraform. Indeed, if I use v2.32.3 of HashiCorp.terraform then it doesn't work. π
https://microsoft.github.io/language-server-protocol/specification#textDocument_foldingRange
There are generally three "kinds" of foldable ranges that LSP supports natively:
In order to support folding of comments we'd need the upstream HCL parser to return comments in the first place, these are currently ignored.
Imports could either be interpreted as
required_providers
block, or just not reported at all.We can also report any additional kinds as the
kind
in the protocol spec is technically juststring
. For example gopls chooses to report all kinds of foldable ranges, such as function calls, struct declarations, switch case statements etc.: https://github.com/golang/tools/blob/8c34cc9cafff8f13c3f3ed95a11de309752c1c60/internal/lsp/source/folding_range.go#L68-L128It is unclear however how any custom kinds would be surfaced to the user and whether a custom kind (as opposed to just empty string, like gopls uses) is even useful in practice.