Skip to content

Terraform Extra

lang.terraform adds Terraform and HCL support through terraform-ls, with terraform fmt formatting and tflint linting.

Enable it

-- ~/.config/blak/lua/blak/user.lua
return {
extras = {
enabled = {
"lang.terraform",
},
},
}

Or enable it interactively:

:BlakExtras enable lang.terraform

What it adds

SurfaceContribution
Treesitterterraform, hcl
Masontflint
LSPterraformls
Formattingterraform_fmt for terraform, terraform-vars
Lintingtflint for terraform

terraformls installs automatically through Mason (package terraform-ls).

terraform_fmt shells out to the terraform CLI, which must be on your $PATH. terraform-ls does not serve generic .hcl files (Packer, Nomad), so HCL receives Treesitter highlighting only.

Configure terraform-ls

return {
extras = { enabled = { "lang.terraform" } },
lsp = {
servers = {
terraformls = {
settings = {
terraform = {
validation = { enableEnhancedValidation = true },
},
},
},
},
},
}

Install and verify

:BlakToolsInstall
:BlakTreesitterInstall
:BlakDoctor

Open a .tf file and check :LspInfo for terraform-ls. Ensure the terraform CLI is installed for format-on-save to work.