A screenshot that shows the Terramate Language Server in Vim

Introducing the Terramate VSCode Extension and Language Server

Sören Martius
Terramate Blog
Published in
3 min readJun 29, 2022

--

Terramate is a Terraform orchestrator and code generator that helps teams achieve Terraform at any scale.

While testing Terramate, some of you fine folk asked us to provide you with a better development experience. And because our main mission is to make you happy, we did.

Today we are happy to introduce two exciting new open source projects: the Terramate VSCode Extension and the Terramate Language Server.

Both projects are in their early stages and the feature list is still small but we believe that by releasing our work earlier, we can get that feedback and build a product the community needs.

The VSCode extension is just the beginning, as we focused on supporting the Language Server Protocol, which means we could support all editors that implement it. We will provide official documentation for the other editors in the upcoming releases of the Terramate Language Server.

We launched a Terramate Discord Server for you to ask questions about Terramate, suggest new features, connect with other members and broaden your circle to learn from one another. If you are working with Terramate, we recommend you join!

👉 https://terramate.io/discord

How to install

The VSCode extension is released in two widely used marketplaces, the official Visual Studio Marketplace from Microsoft and the Open VSX Registry from the Eclipse Foundation.

But before installing the extension, you need to install the Language Server, part of the Terramate repository. This can be done by downloading a release binary or using alternative installing methods such as go install or asdf. For an overview of installation methods available please see the docs at https://terramate.io/docs/cli/installation.

When installed, you can go ahead and install the VSCode extension from the Extensions Panel CTRL+SHIFT+Xin the VSCode Editor, just search for “Terramate”, click on the extension, and the blue Install button.

Installing the Terramate VSCode extension

When done, you’re ready to begin editing Terramate configuration!
For detailed setup information, please check the project’s README.

How to use

If you have the *.hcl file extension associated with other extensions (eg.: Terraform) you can add a specific file association for Terramate in the Settings -> Text Editor -> Files -> Associations or directly byupdating the file.associations option in the settings.json.
See the example below:

Configure *.tm.hcl files with the Terramate Language Server in VSCode

Then just open any .tm or .tm.hcl file and start coding! The extension will highlight the Terramate syntax and give diagnostics for any change in the file.

See the complete example below:

The Terramate VSCode Extension in action

Features

Syntax highlight

The extension highlights HCL language constructs (attributes, blocks, literals, types, etc) and recognizes Terramate keywords.

HCL-aware editing

The extension configures the editing features of VSCode for HCL. Example:

  • CTRL+/ inserts an HCL line comment (#)
  • CTRL+SHIFT+A inserts an HCL block comment (/* … */)
  • It automatically closes bracket-like constructs ([, { and () and you can use the standard VSCode shortcuts to navigate them (CTRL+SHIFT+| for jumping to the end of a block, etc).

Real-time file diagnostics

For each file change (and save), the extension will asynchronously execute linters in the configuration directory and provide diagnostics for syntax errors, invalid Terramate schema, and configuration conflicts.

We will add more features over time. For requesting specific features, please create an issue in one of the repositories ( https://github.com/terramate-io/terramate or https://github.com/terramate-io/vscode-terramate ).

Also, If you’d like to know more about how Terramate can help your team manage infrastructure as code more efficiently, don’t hesitate to reach out to us at hello@terramate.io

This article originally appeared in Rethinking IaC on June 29, 2022

--

--

I like simplicity, pragmatism and common sense while bridging business, product and technology.