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

Feature Request: Support pretty-printing collection types #732

Open
Xulei-NL opened this issue Feb 12, 2025 · 0 comments
Open

Feature Request: Support pretty-printing collection types #732

Xulei-NL opened this issue Feb 12, 2025 · 0 comments

Comments

@Xulei-NL
Copy link

Xulei-NL commented Feb 12, 2025

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

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

No branches or pull requests

1 participant