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

Hashicopr terraform and hcl version conflicting #1654

Open
1 task
evertonspader-tomtom opened this issue Dec 13, 2023 · 1 comment
Open
1 task

Hashicopr terraform and hcl version conflicting #1654

evertonspader-tomtom opened this issue Dec 13, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@evertonspader-tomtom
Copy link

Extension Version

v2.29.1

VS Code Version

Version: 1.84.2 (Universal)
Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
Date: 2023-11-09T10:52:33.687Z (1 mo ago)
Electron: 25.9.2
ElectronBuildId: 24603566
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 23.1.0

Operating System

macOS Sonoma 14.1.1

Terraform Version

Terraform v1.6.2 on darwin_arm64

Steps to Reproduce

Create a terragrunt.hcl file with any unformatted configuration and save it.

Expected Behavior

*.hcl files should be formatted on save

Actual Behavior

Auto format not working

Terraform Configuration

No response

Project Structure

No response

Gist

No response

Anything Else?

I am posting here as it seems that vscode hcl is not very active.

I have both extensions terraform and hcl installed on VSCode and I would like both terraform and terragrunt files to be auto-formatted on save but *.hcl files don't work at all. This is my VSCode settings.

"files.associations": {
  "*.hcl": "hcl",
  "*.tf": "terraform",
},
"[hcl]": {
  "editor.tabSize": 2,
  "editor.defaultFormatter": "hashicorp.hcl",
  "editor.formatOnSave": true
},
"[terraform]": {
  "editor.tabSize": 2,
  "editor.defaultFormatter": "hashicorp.terraform",
  "editor.formatOnSave": true
},

Workarounds

No response

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@evertonspader-tomtom evertonspader-tomtom added the bug Something isn't working label Dec 13, 2023
@jpogran
Copy link
Contributor

jpogran commented Dec 13, 2023

Hi @evertonspader-tomtom, the vscode-hcl extension does not provide a formatting feature for HCL files, so it will not be able to format any kind of HCL files. It only provides syntax highlighting, as described in the README. There is an existing issue asking for formatting support, which explains the complexity and reason it is not supported yet: hashicorp/vscode-hcl#98

The vscode-terraform extension provides a formatter for that is already configured out of the box to format *.tf files. You do not need to set file associations inside your settings, as both the HashiCorp HCL and Terraform extensions automatically configure those at runtime.

Terragrunt files are a separate product, so you will have to look to product for formatting support. The vscode-hcl extension can provide syntax highlighting for any HCL compliant file, but product specific features like Terragrunt require specific support by those products.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants