Add syntax highlighting support for Terraform / HCL files #3226
Zak Siddiqui opened 15 hours ago

Add syntax highlighting support for Terraform / HCL files.

Currently .tf, .tfvars and .hcl files are not mapped to any highlighter mode, so they always render as plain text in blob and diff views. Highlighting is selected purely from the file extension, and since these extensions are absent from the bundled mode table, there is no way to get colors for Terraform files.

Proposed solution

Register an HCL/Terraform mode in the highlighter mode table and map the following extensions to it:

  • .tf
  • .tfvars
  • .hcl

Preferably also support .tf.json / .tfvars.json (Terraform's JSON variants), which can reuse the existing JSON mode.

Expected behavior

Terraform files are displayed with HCL-aware highlighting — comments (#, //, /* */), strings and heredocs, numeric literals, block types and keywords (resource, variable, module, provider, locals, data, output, terraform, ...), and interpolation sequences such as ${...} inside strings.

1/1
Type
Enhancement
Priority
Minor
Assignee
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-3226
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover