pygments
pygments copied to clipboard
HashiCorp Configuration Language (HCL) Support
The HashiCorp Configuration Language (HCL) is becoming very popular these days and also very handy to have in other projects such as MediaWiki, which make use of pygments.
Specification: https://github.com/hashicorp/hcl
@hairmare ^
pygments does support HCL but you have to label it as terraform
which isn't 100% accurate, but seems to work pretty well for me.
Good catch, totally missed that one. Thanks!
Can you please have a look at #1756? Feedback is welcome. Thanks!
@lgiordani I have a block that looks like this, which is failing when using pygments 2.9.0 with WARNING: Could not lex literal_block as "terraform". Highlighting skipped.
Strange thing is this syntax is valid with both HCL 1 and HCL 2, and it was working fine with pygments 2.8.1.
```terraform
provider "aws" {}
module "test-lx-instance" {
source = "git::https://github.com/plus3it/terraform-aws-watchmaker//modules/lx-instance/"
Name = "tf-watchmaker-lx-autoscale"
AmiId = "__AMIID__"
AmiDistro = "__AMIDISTRO__"
}
@lorengordon I'll have a look as soon as possible, thanks for the test case
Can someone confirm this fixed by #1756? I see an error on the first }
but that seems unrelated?
I am using terragrunt that also uses HCL for configuration. The changes from #1756 do not fix that. Should I open another issue for this (even though it's using HCL)?
An example for terragrunt's configuration is below:
terraform {
source =
"github.com:foo/infrastructure-modules.git//app?ref=v0.0.1"
}
inputs = {
instance_count = 10
instance_type = "m4.large"
}
Given #1756 doesn't fix your issue, but is already merged, I'd suggest to open a new one. For my understanding: Is terragrunt using a dialect of HCL or is that a problem for "plain" HCL?
@Anteru The linked PR #1756 is included in the 2.9.0 release and does not appear to fix this issue. I can't test what it does work for, but it does not work for basic Terraform syntax that is the same in both HCL2 and HCL1, as I mentioned above.
Hi all, my work on #1756 was checked against a large Terraform code base (~100k lines), but I didn't implement the HCL specification following it rule by rule, so I'm not surprised that isn't covered. I think it's simpler to open a new issue with the failing use case and steps to reproduce so that whoever has time to look into it can easily create the test environment.
@lgiordani Just closing the loop, there's a patch for the problem I was noticing in #1987 ...
Thank you @lorengordon!
There's a chance support for the syntax regression I mentioned was fixed in #2097. Just waiting on the next release to test it.
Can confirm #2097 fixed the issue for us, in the 2.12.0 release.
Thank you @lorengordon!