-
Notifications
You must be signed in to change notification settings - Fork 180
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
meta: Product-agnostic HCL syntax highlighting #638
Comments
Hello, just curious about the status of this? Asking for a friend who's learning Packer and would like |
@simonkeng It's not on our near-term roadmap currently, but I would recommend you to upvote this issue and subscribe to get notified when we start working on this. |
Okay got it. Thanks for the info @radeksimko |
This has already been called out in other tickets, but I wanted to mention here: Having this would make using tools like Terragrunt much easier. |
I can't explain more at the moment, but this is something we're actively working on and will have more information in the coming weeks. |
@jpogran Very exciting! I understand if you can't speak much to this, but would this work be related to anything on existing product roadmap items you share either publicly or with Hashicorp clients? |
I second the modification to allow something like terragrunt to be used effectively. In the most recent updates the language server is undoing a format I need to make the get_env function to work as a standalone call |
Can you explain further on what do you mean by this? Generally the Terraform language server never supported Terragrunt. If it ever worked, it was likely by accident. More details and context is yet to come, but you can try out https://marketplace.visualstudio.com/items?itemName=HashiCorp.HCL which should highlight Terragrunt config files without issues, since these files follow As for IntelliSense, we do not intend to provide that as part of the Terraform extension nor Terraform LS, since Terragrunt has its own schema (own keywords in its config files). We'd be however happy for anyone to create a dedicated Terragrunt extension and/or language server, which claims As for building out the language server, we maintain https://github.com/hashicorp/hcl-lang which has still experimental (unstable) API, but is designed to be used to build any HCL2-based language server, such as Terragrunt one. |
We now maintain a dedicated repository for the HCL grammar which also includes plenty of tests. That HCL grammar is in turn used by a recently updated HCL extension - so you can use it for highlighting any
This is tracked under hashicorp/syntax#35
This is tracked under hashicorp/syntax#39 I have explained our intentions with regards to Terragrunt in more detail under #239 (comment) |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Problem Statement
Most editors, plugins, extensions (including this Terraform VS Code extension), or websites wanting displaying files with some flavour of HCL (such as Terraform language) need a way of highlighting these files.
The fundamental problem of highlighting involves answering two (related) questions:
*.tf
as Terraform configurationOften times implementations start by supporting a single flavour of HCL, such as Terraform and many end there, or just decide to treat different HCL flavours as equivalent, e.g. highlight Nomad job spec with the same set of rules as Terraform configuration.
This creates a few challenges as described below.
Differences between Terraform versions
Terraform language contains a number of components which change between versions. For example function names, or block types. Product-specific highlighting often hard-codes such components, which makes it version-specific.
For example
alltrue
oranytrue
functions were added in Terraform 0.14.0, but are highlighted differently (in this VS Code extension) than other functions introduced earlier (such aslower
ormax
):Other HCL-based languages
Reusing the same implementation which is tailored for one product (Terraform) results in inaccurate and incomplete
highlighting.
While the underlying parser is the same and components available within HCL2 are the same, the highlighting differs in small subtle ways. This results in inconsistent and suboptimal experience across HashiCorp products.
For example Packer template highlighted with Terraform VS Code extension:
or Nomad job spec
User Impact
All users of VS Code Terraform extension would benefit from more accurate highlighting of Terraform configurations.
At the time of writing there's close to 18 000 public repositories on GitHub which are detected as majority HCL (with close to 1M files across them). All of these files in these repositories could be highlighted more accurately.
Visitors of all HashiCorp
.io
product sites contain snippets of HCL configurations which would benefit from more accurate highlighting.Expected User Experience
terraform.io
and other HashiCorp.io
websites see snippets of HCL2 code highlighted accuratelyProposal
hashicorp/hcl-grammar
to host the HCL grammar*.tf
files (while assuming that any richer highlighting experience can be provided via LS)*.tf
,*.hcl
and other known extensionsBlocking Questions (Optional)
The text was updated successfully, but these errors were encountered: