Syntax highlighting is not working reliably
See original GitHub issueVersions
This bug is reproducible in:
- the latest version of the extension (below)
- the latest version of the language server (below)
Extension
v2.19.0
Language Server
terraform-ls 0.25.2
VS Code
Version: 1.64.2
Commit: f80445acd5a3dadef24aa209168452a3d97cc326
Date: 2022-02-09T22:00:58.347Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 20.6.0
Operating System
macOS Big Sur 11.6.2 (20G314)
Terraform Version
$ terraform version
Terraform v1.1.5
on darwin_amd64
Steps To Reproduce
Steps to reproduce the behavior:
- Create a main.tf with the content of the screenshots, the syntax highlight does not work.
- The default language will be “Terraform”
- Hit Ctrl+Shift+P and “Change Language Mode -> terraform-vars”
- The syntax highlight works
This is weird and feels not intended.
Include any relevant Terraform configuration or project structure:
resource "azurerm_resource_group" "main" {
name = local.resource_group_name
location = var.location
tags = local.all_tags
}
Please, see screenshots attached.
Weirdly working terraform-vars:

Not working Terraform:

Expected Behavior
Syntax highlighting should just work. Why are there two languages anyway?
Actual Behavior
Syntax highlighting does not work. 😦
Additional context
Extension bisect/only enabling Hashicorp Terraform extension did not fix the problem.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (11 by maintainers)
Top Results From Across the Web
Visual Studio Code syntax highlighting is not working for ...
Previously, I had experienced this issue with CSS after installing POSTCss extension. I looked if this only happens with a specific language.
Read more >Broken syntax highlighting for shell scripts - Issues - GitLab
The immediate fix would be to fix the mapping between the two languages, that is [rouge]: shell -> [highlight.js]: sh . Additionally, we...
Read more >Javascript syntax highlighting it not working
After I enabled the extension, syntax highlighting started working again. Go to Tools > Extensions and Updates > Installed. And look for "Visual...
Read more >improved syntax highlighting in VSCode extension ...
Semantic highlighting is not instant - VSCode will actively ask our language server to provide a set of semantic tokens for an entire...
Read more >Kotlin syntax highlighting not working | Bitbucket Cloud - Jira
Kotlin syntax highlighting not working. Gathering Impact: Assignee: Priority: Resolution: Gathering Impact. Unassigned. Medium. Unresolved. Component/s.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

FYI, I’ve created two issues tracking the described problems:
Oh well, with your explanation I just realized that I had completely wrong (other?) assumptions about what the extension provides. I thought the keyword
var.will be highlighted to aid with visual reviews. But now I understood that e.g.var.existing_varwill be displayed inline (without any highlighting) since this is a known reference. This becomes even clearer when I hover over that variable.I really learned a lot about debugging vscode extensions as well as how they work internally. I guess there is nothing to “fix” in this issue. I see exactly the same improvement that you mentioned:
I’m closing this issue now since it is none. Feel free to re-open it if needed.
Thanks again! 🥇