VladRassokhin / intellij-hcl

HCL language support for IntelliJ platform based IDEs
Apache License 2.0
244 stars 47 forks source link

Add formatter action for HCL/terragrunt #291

Open misha-ridge opened 4 years ago

misha-ridge commented 4 years ago

Prerequisites

Installation details

Terraform Configuration Files

N/A

Exception

N/A

Expected Behavior

Open a *.hcl file, search for "reformat with hclfmt" in menu.

Actual Behavior

No option to format with hclfmt. "Reformat Code" action is not a substitute (#141).

Steps to Reproduce

See above.

Notes

There is hclfmt and there is terragrunt hclfmt bundled in Terragrunt.

VladRassokhin commented 4 years ago

I'd recommend to configure and use File Watcher

matthewhembree commented 3 years ago

I'd recommend to configure and use File Watcher

I guess that's one way to do it. I use the Jetbrains Pre-commit action of terraform fmt. image

It tries to run terraform fmt on .hcl files. An returns the error:

Error: Only .tf and .tfvars files can be processed with terraform fmt

As a workaround, I setup File Watchers for terraform fmt and terragrunt hclfmt. It seems that File Watcher only triggers off of an explicit save action (cmd-s). image

It would be helpful if the Pre-commit action would not pass .hcl files to terraform fmt.

Thanks!

aberenshtein commented 2 years ago

Any news here?