Vscode-terraform: Highlighting issue

Created on 15 Aug 2018  ยท  3Comments  ยท  Source: hashicorp/vscode-terraform

Highlighting seems to only work with this syntax:

os_profile_linux_config {
    ssh_keys {
      path = "/home/${var.admin_user}/.ssh/authorized_keys"
      key_data = "${var.vm_ssh_key}"
    }
    disable_password_authentication = true
  }

Though this is valid syntax for terraform as well and breaks the highlighting:

os_profile_linux_config {
    ssh_keys = {
      path = "/home/${var.admin_user}/.ssh/authorized_keys"
      key_data = "${var.vm_ssh_key}"
    }
    disable_password_authentication = true
  }

screen shot 2018-08-15 at 12 43 50 pm
screen shot 2018-08-15 at 12 43 59 pm

syntax

Most helpful comment

The screenshots looks like the language might be set to HCL instead of Terraform.

In your screenshot, the colorization of references, like var.admin_user, are colored in two different colors.

  • This isn't possible with the terraform language extension (this repo), because the entire string inside ${} has the same theme selector: "entity.other.attribute-name".

    • Thus there is no way for a theme to color them differently

  • This is possible with HCL language extension as it has more theme selectors

    • the first element inside ${} as "storage.modifier.hcl"

    • other elements inside ${} are defined as "entity.name.type.hcl"

  • Moreover, the HCL language extension has several open issues regarding syntax highlighting

    • I suspect this is another one

Here's a quick comparison of a syntax highlighting between the two

Terraform Language Extension

terraform-language

HCL Language Extension

hcl-language

All 3 comments

The screenshots looks like the language might be set to HCL instead of Terraform.

In your screenshot, the colorization of references, like var.admin_user, are colored in two different colors.

  • This isn't possible with the terraform language extension (this repo), because the entire string inside ${} has the same theme selector: "entity.other.attribute-name".

    • Thus there is no way for a theme to color them differently

  • This is possible with HCL language extension as it has more theme selectors

    • the first element inside ${} as "storage.modifier.hcl"

    • other elements inside ${} are defined as "entity.name.type.hcl"

  • Moreover, the HCL language extension has several open issues regarding syntax highlighting

    • I suspect this is another one

Here's a quick comparison of a syntax highlighting between the two

Terraform Language Extension

terraform-language

HCL Language Extension

hcl-language

Version 2.0+ of the extension handles both of those cases correctly, so I'm going to close this. Thanks!

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the context necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brodster2 picture brodster2  ยท  5Comments

renanaraujo picture renanaraujo  ยท  5Comments

avinashkavi447 picture avinashkavi447  ยท  7Comments

fcatacut picture fcatacut  ยท  5Comments

sugarraysam picture sugarraysam  ยท  4Comments