hcl
hcl copied to clipboard
Feature Request: Support pretty-printing collection types
Dear all,
I would like to see terraform fmt support pretty-printing collection types. Currently I observe that internal terraform fmt code runs format passes on fixed lines (please see format.go). But I hope it can help me format variables of collection types (list, set, map), for instance
variable "example_set" {
type = set(string)
default = ["foo", "bar", "dog", "cat", "jojo"]
}
# reformatted to =========================>
variable "example_set" {
type = set(string)
default = [
"foo",
"bar",
"dog",
"cat",
"jojo"
]
}
To my understanding, implementing this feature requires replacing the current []formatLine with other data strucutres like linked lists to allow flexible line insertions.
I hope you can put my feature request on your radar! If you don't mind, I'm also willing to implement it if you agree.
Best regards,
Xulei