The old version of the Terraform extension formatted .tfvars files so why doesn't the new version? Please restore this feature.
Thanks
@radeksimko do you know if this is a limitation in the LS currently or something where the extension is just not sending it?
Correct, this is a temporary limitation on the LS side where the extension intentionally isn't sending tfvars files to it (yet), because:
languageId which tfvars should be sent asMost of the work is tracked under https://github.com/hashicorp/terraform-ls/issues/50 - i.e. I'd love to support it at some point.
I am fairly sure the old extension was interpreting tfvars the same way as tf (most other community extensions do), which is wrong because the syntax is not the same.
Before we support it on the server side though there's some work to do on client side too.
The extension should be treating tfvars differently during syntax highlighting. e.g. I don't think tfvars supports interpolation, function calls, provider/resource/data blocks etc. so these things should not be highlighted there as it gives the user false impression that it is supported. And neither does plain HCL support any of this, which seems to be still highlighted the same way too, giving the same false impression.
In the meantime, you can configure the file association in VS Code for all *.tfvars to Terraform. Even if syntax is not the same, the formatting works as I expect in most cases.
See Language Identifiers for more info.
If anyone is wondering how to write this in your settings.json - something like this:
"files.associations": {
"*.tfvars": "terraform"
},
Most helpful comment
In the meantime, you can configure the file association in VS Code for all
*.tfvarstoTerraform. Even if syntax is not the same, the formatting works as I expect in most cases.See Language Identifiers for more info.