Skip to content

sublimelsp/LSP-terraform

Repository files navigation

LSP-terraform

A convenience package to take advantage of the Terraform Language Server.

Installation

  1. Install LSP, LSP-terraform and Terraform Syntax from Package Control.
  2. Restart Sublime Text.
  3. (Optional but recommended) Install the LSP-file-watcher-chokidar via Package Control to enable functionality to notify the server about new files.

Optionally install the Terraform CLI for the validateOnSave and formatting functionality.

Configuration

You may edit the default settings by running Preferences: LSP-terraform Settings from the Command Palette.

Optionally you can view terraform-ls settings at Hashicorps repo

Formatting

The server supports formatting for the terraform files (equivalent to running terraform fmt). You can either trigger it manually from the Command Palette using the LSP: Format File command or automatically run it on saving the file. To enable formatting on save, open Preferences: LSP Settings from the Command Palette and add or modify the following setting:

{
    "lsp_code_actions_on_save": {
      "source.formatAll.terraform": true,
    },
}