vscode-language-terraform icon indicating copy to clipboard operation
vscode-language-terraform copied to clipboard

Feature Request: formatting

Open mpicard opened this issue 4 years ago • 2 comments

It would be really cool if the plugin could run something like terraform fmt FILE on the current file, on save or something

mpicard avatar Sep 17 '20 14:09 mpicard

For reference: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting

goetzc avatar Dec 17 '20 18:12 goetzc

While the official HashiCorp plugin does this, I much prefer this plugin (lightweight and simple). However, not having this feature really slows down my workflow. However, I did find a decent workaround to replicate this feature, via an external plugin: https://github.com/emeraldwalk/vscode-runonsave

I added this to my settings.json:

"emeraldwalk.runonsave": {
        "commands": [
            {
                "match": ".tf",
                "cmd": "terraform fmt ${file}"
            },
        ]
}

And now I can have terraform fmt run after I save .tf files. Nevertheless, it would be really nice if this is supported natively.

maishiroma avatar May 03 '21 18:05 maishiroma

I'd also like to have a formatting function.

mibadim avatar Jan 09 '23 17:01 mibadim