Skip to main content

Terraform

info

You can enable the extra with the :LazyExtras command. Plugins marked as optional will only be configured if they are installed.

Alternatively, you can add it to your lazy.nvim imports
lua/config/lazy.lua
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.lang.terraform" },
{ import = "plugins" },
},
})

Below you can find a list of included plugins and their default settings.

caution

You don't need to copy the default settings to your config. They are only shown here for reference.

nvim-treesitter

opts = { ensure_installed = { "terraform", "hcl" } }

nvim-lspconfig

opts = {
servers = {
terraformls = {},
},
}

mason.nvim

ensure terraform tools are installed

opts = { ensure_installed = { "tflint" } }

telescope-terraform-doc.nvim

opts = {}

telescope-terraform.nvim

opts = {}

none-ls.nvim (optional)

opts = function(_, opts)
local null_ls = require("null-ls")
opts.sources = vim.list_extend(opts.sources or {}, {
null_ls.builtins.formatting.packer,
null_ls.builtins.formatting.terraform_fmt,
null_ls.builtins.diagnostics.terraform_validate,
})
end

nvim-lint (optional)

opts = {
linters_by_ft = {
terraform = { "terraform_validate" },
tf = { "terraform_validate" },
},
}

conform.nvim (optional)

opts = {
formatters_by_ft = {
hcl = { "packer_fmt" },
terraform = { "terraform_fmt" },
tf = { "terraform_fmt" },
["terraform-vars"] = { "terraform_fmt" },
},
}

telescope.nvim (optional)

opts = nil