cmur2 / language-terraform

Terraform.io support for Atom
MIT License
49 stars 32 forks source link

HCL in grammar fileTypes causes conflicts #55

Closed mschuchard closed 3 years ago

mschuchard commented 3 years ago

Currently hcl is listed in the grammar fileTypes at: https://github.com/cmur2/language-terraform/blob/master/grammars/terraform.cson#L6

This causes conflicts with e.g. Packer templates and Vault policies. Unfortunately, the global config.cson does not allow grammar overriding with its customFileTypes. Currently I remove hcl from the fileTypes in my local Terraform grammars, but it would be nice if this was somehow configurable or removed entirely.

cmur2 commented 3 years ago

Which grammar do you use for Packer templates and/or Vault policies?

I merged https://github.com/cmur2/language-terraform/issues/49 because someone claimed it would be helpful for Terragrunt in https://github.com/cmur2/language-terraform/issues/48, but I'm also open to revert it if the ecosystem changed in the meanwhile and there are other good grammars out there. In general, it's probably easier for a user to configure using a syntax for an additional fileType than removing it.

mschuchard commented 3 years ago

Packer templates and Vault policies are both source.hcl currently. If I use a .hcl extension, for some reason language-terraform grammar takes precedence over language-hcl grammar. Also for some reason the Atom global config.cson with its fileTypes cannot override either package's grammar.

Terragrunt uses source.hcl also. I see #48 and #49, and the optimal resolution there would have been for the user to install language-hcl since the files are HCL files and not Terraform configs. Perhaps the user did not know about the language-hcl package and thought adding hcl to language-terraform would be an alternative?

cmur2 commented 3 years ago

Interestingly, in https://github.com/fd/language-hcl/blob/master/grammars/hcl.cson the language-hcl also claims to support .tf files which (given that it was last released in 2016) is also not too user-friendly, so maybe that's why the author of https://github.com/cmur2/language-terraform/issues/48 didn't use it?

Anyways, I tend to agree with the arguments of @mschuchard here and will revert https://github.com/cmur2/language-terraform/pull/49 and perform a new release.

mschuchard commented 3 years ago

Now I remember a couple of times where my Terraform configs auto-loaded as HCL instead. Sounds like I may have to go locally modify that package also.

Thanks for the resolution. This enables me to not have to implement a workaround for Packer and Vault where source.terraform is also potentially considered a Packer template and Vault policy.

cmur2 commented 3 years ago

Close via 2b4d3fd862ec859c9a644208aa1dd3533d9aaa28

cmur2 commented 3 years ago

Version 0.9.7 is released.