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

Support folding ranges #105

Open
paultyng opened this issue May 21, 2020 · 18 comments
Open

Support folding ranges #105

paultyng opened this issue May 21, 2020 · 18 comments

Comments

@paultyng
Copy link
Contributor

paultyng commented May 21, 2020

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 just string. 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-L128

It 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.

@paultyng paultyng added the enhancement New feature or request label May 21, 2020
@paultyng paultyng added this to the v0.5.0 milestone May 21, 2020
@amasover
Copy link
Contributor

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!

@paultyng
Copy link
Contributor Author

@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.).

@radeksimko radeksimko modified the milestones: v0.5.0, v0.6.0 Jul 10, 2020
@radeksimko radeksimko added the lsp label Jul 29, 2020
@radeksimko radeksimko modified the milestones: v0.6.0, v0.7.0 Aug 7, 2020
@radeksimko radeksimko modified the milestones: v0.7.0, v0.8.0 Sep 2, 2020
@radeksimko radeksimko modified the milestones: v0.8.0, v0.9.0 Nov 4, 2020
@radeksimko radeksimko removed the lsp label Aug 5, 2021
@radeksimko radeksimko changed the title Support folding blocks Support folding ranges Aug 25, 2021
@PePoDev
Copy link

PePoDev commented Oct 1, 2021

@paultyng I have try with this, But not working.

#region test
variable "test" {
  type        = bool
  default     = true
}
#endregion

@jpogran
Copy link
Contributor

jpogran commented Oct 4, 2021

@PePoDev we haven't implemented region folding yet. When we do you'll see a PR and a line item in our changelog

@aleqsss
Copy link

aleqsss commented Jan 20, 2022

Hi,

I'm also interested in region folding, any news in regards of this? 🙂🤞

@dbanck
Copy link
Member

dbanck commented Jan 20, 2022

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.

@aleqsss
Copy link

aleqsss commented Jan 20, 2022

Understood, and thank you for the information!

@garsiv1932
Copy link

Hello, is this feature implemented?

@dbanck
Copy link
Member

dbanck commented Mar 25, 2024

@garsiv1932 Sorry, but we haven't implemented region folding yet

@garsiv1932
Copy link

Is it too difficult?

@jpogran
Copy link
Contributor

jpogran commented Mar 25, 2024

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.

@garsiv1932
Copy link

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.

@jpogran
Copy link
Contributor

jpogran commented Mar 26, 2024

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:

Screen.Recording.2024-03-26.at.9.44.59.AM.mov

@garsiv1932
Copy link

I had a conflict on my extensions, is working right now.

@artemudovyk
Copy link

artemudovyk commented Aug 29, 2024

The syntax is #region and #endregion:

Sorry for nitpicking, but why are version with whitespace # region and # endregion not supported?
image

The format you mentioned is working fine though:
image

@rcjsuen
Copy link

rcjsuen commented Oct 13, 2024

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

image

@artemudovyk
Copy link

@artemudovyk Is this still a problem for you? It seems to be working for me

Yeah, it's still the same for me.

@rcjsuen
Copy link

rcjsuen commented Oct 13, 2024

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. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants