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 a generic hcl formatter (hclfmt) #402

Merged
merged 2 commits into from
May 13, 2024
Merged

Conversation

jonasohland
Copy link
Contributor

Adds a generic formatter for hcl files.

I realize that there are already 2 formatters for hcl files defined in this repo, but to use either one of them, you need to have the specific tool installed (terraform or packer).

Meant to be used with the hclfmt binary that is built from the hcl project. This is also the one that can be obtained with mason: registry link.

Formats input from stdin and writes to stdout.

@github-actions github-actions bot requested a review from stevearc May 13, 2024 13:49
@stevearc
Copy link
Owner

Thanks for the PR!

@stevearc stevearc merged commit 37cbcea into stevearc:master May 13, 2024
8 checks passed
@lamchau
Copy link
Contributor

lamchau commented Aug 22, 2024

in case someone was looking on how to add this as a standalone and to save some time - since i was expecting

hcl = { "hclfmt" }

since some/most formatters match the binary (maybe we'd rename hcl.lua to hclfmt.lua (but maybe not since there are multiples of that)

require("conform").setup({
  formatters_by_ft = {
    hcl = { "hcl" },
  }
});

install via just go

go install github.com/hashicorp/hcl/v2/cmd/hclfmt@latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants