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

Add hcl extension support #602

Closed
IxDay opened this issue Apr 2, 2021 · 6 comments
Closed

Add hcl extension support #602

IxDay opened this issue Apr 2, 2021 · 6 comments

Comments

@IxDay
Copy link

IxDay commented Apr 2, 2021

Is it possible to add support for .hcl file extension with this plugin?
Since terraform code is actually hcl + tfvars files can also be hcl it could make sense, right?
I checked the vscode plugin registry and it seems that there is no entry for this kind of files and maybe this one could handle it as it holds all the needed features

@allthingsclowd
Copy link

Agree 100% with @IxDay above.
When developing a new Packer HCL2 template within CodeSpaces, the VSCode Editor does not recognise the .pkr.hcl extension.

Simply adding the .tf extension to my packer template file fixes the syntax highlighting within the editor however this then breaks Packer validation.

E.g.
codespace ➜ /workspaces/packer-vsphere (AddTFCAgent ✗) $ packer validate "example.pkr copy.hcl.tf" Failed to parse file as legacy JSON template: if you are using an HCL template, check your file extensions; they should be either *.pkr.hcl or *.pkr.json; see the docs for more details: https://www.packer.io/docs/templates/hcl_templates.

Thank you

@radeksimko
Copy link
Member

radeksimko commented Apr 9, 2021

Hi folks,
Improving editor experience (via highlighting and other features) for "plain" (unknown) HCL or Packer/Nomad/... HCL flavour is something we keep under review. We do not have a solution for this yet though.

The key thing to understand here is that these languages (although based on HCL) differ.

  • This probably shouldn't matter for simple syntax highlighting grammar, but the grammar we use currently actually is Terraform specific and will be inaccurate for any other HCL languages at this point. One possible course of action we're considering here is to make a generic HCL grammar which supports (or aims to support) superset of all HCL2 features across known deployments (i.e. Packer, Nomad etc.). While such grammar may end up replacing the current one in this Terraform plugin, it's likely we would create a dedicated small HCL plugin that leverages the same grammar people can use if there isn't a product-specific plugin (e.g. Packer one). i.e. a "Terraform" plugin likely will never claim to support plain hcl, but an "HCL" plugin would. This is not only for clean separation of concerns, but also to avoid problems where VS Code doesn't seem to handle conflicts well between two plugins claiming the same file extension.
  • This matters for any other features, such as formatting, completion, hover, etc. which all require much deeper understanding of the flavour of HCL used by each individual product because each product uses different language constructs (block names, attributes, functions, way of formatting configs etc.). This could potentially be addressed by a dedicated Packer, Nomad etc. plugin which in turn talks to dedicated Packer/Nomad/... language server, similar to https://github.com/hashicorp/terraform-ls

@allthingsclowd
Copy link

Makes sense, thank you for the explanation. I made the assumption all things HCL were equal.

@julian-alarcon
Copy link

julian-alarcon commented Jul 23, 2021

A PR is available to add .hcl #615

@radeksimko
Copy link
Member

Hi folks,
#638 and #639 outline our plans for handling other non-Terraform HCL files.

TL;DR we plan to have a dedicated extension which would most likely claim *.hcl only and that extension would provide all HCL-generic functionality, such as highlighting that is relevant for any HCL file (without knowing whether it's Terraform, Packer, Nomad, Waypoint or anything else).

In the interest of keeping conversations in one place I'm going to close this issue in favour of the two mentioned ones.

Thanks!

@github-actions
Copy link

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.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants