null-ls.nvim
null-ls.nvim copied to clipboard
Add HCL format builtin
Issues
- [X] I have checked existing issues and there are no existing ones with the same request.
Feature description
Hello,
I would like to see hclfmt, - a HCL configuration file formatter - supported as a built-in in null_ls. I done it locally and it is working fine.
Although I would like to make a pull request to apply the change, I understand that the contribution is too small for me being one of the null_ls contributors able to make a PR.
Below is the change.
Best regards
Help
No
Implementation help
-- lua/null-ls/builtins/formatting/hclfmt.lua
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")
local FORMATTING = methods.internal.FORMATTING
return h.make_builtin({
name = "hclfmt",
meta = {
url = "https://github.com/fatih/hclfmt",
description = "Formatter for HCL configuration files",
},
method = FORMATTING,
filetypes = { "hcl" },
generator_opts = {
command = "hclfmt",
to_stdin = true,
},
factory = h.formatter_factory,
})
Looks good to me - feel free to open a PR (we don't have any restrictions on the size / scope of contributions, and all built-in contributions are always welcome).
Thanks, following is the associated PR #1361
hclfmt project is abandoned, can't you format hcl with terraform fmt?
I will try a hand at moving from hclfmt to terraform fmt.
Thank you for the suggesting that.
There is already a builtin using terraform fmt. I simply bound its execution to hcl and nomad filetypes.
Following is the associated PR #1370
There is already a builtin using
terraform fmt. I simply bound its execution tohclandnomadfiletypes.Following is the associated PR #1370
Yes, that's basically what I do in my config.
null_ls.builtins.formatting.terraform_fmt.with({
extra_filetypes = { "hcl" },
}),