Skip to content

lang: add tofu to hcl file-types - #16375

Open
yu2971512385-ui wants to merge 1 commit into
helix-editor:masterfrom
yu2971512385-ui:lang-hcl-tofu
Open

yu2971512385-ui wants to merge 1 commit into
helix-editor:masterfrom
yu2971512385-ui:lang-hcl-tofu

Conversation

@yu2971512385-ui

Copy link
Copy Markdown

OpenTofu 1.8 added the
.tofu extension so that a module can carry OpenTofu-specific code beside the
Terraform code it replaces: when foo.tofu and foo.tf both exist OpenTofu
loads only foo.tofu, and Terraform ignores .tofu entirely. A directory
written for OpenTofu alone therefore need not contain a single .tf file, and
today those files open with no language attached — no highlighting, no
terraform-ls.

Checked against OpenTofu 1.13.1 rather than taking the release notes on trust:

$ ls
main.tofu
$ tofu apply
Error: No value for required variable
  on main.tofu line 1:
   1: variable "who" {

The file is parsed and diagnostics point into it, so .tofu alone is a complete
configuration.

.tofuvars is deliberately left out: the RFC describes it as the replacement
for .tfvars, but 1.13.1 does not auto-load terraform.tofuvars, and with both
terraform.tfvars and terraform.tofuvars present the .tfvars value is the
one that wins. The .tf.json → .tofu.json replacement needs no entry either,
since those already match on json.

🤖 Generated with Claude Code

OpenTofu 1.8 added the `.tofu` extension so that a module can carry
OpenTofu-specific code beside the Terraform code it replaces: `foo.tofu`
is loaded in place of `foo.tf` when both exist, and Terraform ignores it
entirely. A directory written for OpenTofu alone therefore need not hold
a single `.tf` file, and today those open with no language attached.

Verified against OpenTofu 1.13.1: a directory holding only `main.tofu`
parses and applies, with diagnostics pointing at `main.tofu`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant