Morning all
Apologies if this has been asked before - I didnt see any results from a search.
Is there a recommended theme for terraform when using VScode or IntelliJ ?
Ive tried a few but I find they make the code harder to read.
Hoping theres other themes out there that might be easier on the eye
Thanks in advance
Andy
Hi @andrewglass-bjss
As far as I know there is no HashiCorp-maintained theme for any editor, HCL or Terraform specific and there are currently no intentions to create one.
However, the grammars HashiCorp does maintain (GitHub - hashicorp/syntax: TextMate grammars for highlighting HCL, HCL-based languages and Sentinel. ) should work reasonably well with the default themes in VS Code. Or at least I can say that care was taken to make it so.
I personally use GitHub Theme - Visual Studio Marketplace with success but of course that just reflects my own preference. Your mileage may vary.
Also what may be relevant to mention here for anyone thinking about developing Terraform specific themes is that there is some documentation and semantic tokens which can make this possible/easier:
# Syntax Highlighting
Highlighting syntax is one of the key features expected of any editor. Editors typically have a few different solutions to choose from. Below is our view on how we expect editors to highlight Terraform code while using this language server.
## Static Grammar
Highlighting Terraform language syntax via static grammar (such as TextMate) _accurately_ may be challenging but brings more immediate value to the end user, since starting language server may take time. Also not all language clients may implement semantic token based highlighting.
HashiCorp maintains a set of grammars in https://github.com/hashicorp/syntax and we encourage you to use the available Terraform grammar as the *primary* way of highlighting the Terraform language.
## Semantic Tokens
[LSP (Language Server Protocol) 3.16](https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/) introduced language server-driven highlighting. This language server is better equipped to provide more contextual and accurate highlighting as it can parse the whole AST, unlike a TextMate grammar operating on a regex-basis.
LSP 3.17 does support use cases where semantic highlighting is the only way to highlight a file (through [`augmentsSyntaxTokens` client capability](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#semanticTokensClientCapabilities)). However in the context of the Terraform language we recommend semantic highlighting to be used as in *addition* to a static grammar - i.e. this server does _not_ support `augmentsSyntaxTokens: false` mode and is not expected to be used in isolation to highlight configuration.
There are two main use cases we're targeting with semantic tokens.
### Improving Accuracy
This file has been truncated. show original
This was implemented a while back (almost 2 years ago) and the relevant PR also has an example of what’s possible: Support custom semantic tokens & modifiers by radeksimko · Pull Request #958 · hashicorp/vscode-terraform · GitHub
FWIW The auto-switching of light/dark themes (where the OS theme in itself can be driven by time of day, or sunset/sunrise) is also helpful in alleviating some eye strain. Visual Studio Code Themes
"window.autoDetectColorScheme": true,
I assume that other IDEs may offer similar feature.
system
Closed
August 24, 2024, 7:22pm
4
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.