From dabe99df8807206414546defcbc182e4e5641784 Mon Sep 17 00:00:00 2001 From: alpha2phi Date: Sun, 23 Jul 2023 08:08:21 +0800 Subject: [PATCH] feat: terraform --- lua/pde/terraform.lua | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lua/pde/terraform.lua b/lua/pde/terraform.lua index 39aa381..9da93dd 100644 --- a/lua/pde/terraform.lua +++ b/lua/pde/terraform.lua @@ -2,14 +2,22 @@ if not require("config").pde.terraform then return {} end +vim.api.nvim_create_autocmd("FileType", { + pattern = { "hcl", "terraform" }, + desc = "terraform/hcl commentstring configuration", + command = "setlocal commentstring=#\\ %s", +}) + return { { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) - vim.list_extend(opts.ensure_installed, { - "terraform", - "hcl", - }) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { + "terraform", + "hcl", + }) + end end, }, { @@ -23,11 +31,13 @@ return { { "jose-elias-alvarez/null-ls.nvim", opts = function(_, opts) - local null_ls = require "null-ls" - vim.list_extend(opts.sources, { - null_ls.builtins.formatting.terraform_fmt, - null_ls.builtins.diagnostics.terraform_validate, - }) + if type(opts.sources) == "table" then + local null_ls = require "null-ls" + vim.list_extend(opts.sources, { + null_ls.builtins.formatting.terraform_fmt, + null_ls.builtins.diagnostics.terraform_validate, + }) + end end, }, }