From 790326e3f5cf36d649040cd027a55e0f9187befe Mon Sep 17 00:00:00 2001 From: Ethan Holz Date: Wed, 5 Aug 2026 13:26:21 -0600 Subject: [PATCH] feat: migrate Terraform LS to native config Add the complete native terraform-ls definition and enable it during startup. Preserve the OpenTofu binary override as an initialization option so terraform-ls applies it. Assisted-by: Pi:openai-codex/gpt-5.6-sol --- init.lua | 15 ++++++++++++++- lsp/terraformls.lua | 17 ++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 9b78066..9bb99e4 100644 --- a/init.lua +++ b/init.lua @@ -161,7 +161,20 @@ end require("mappings") require("lsp") vim.cmd("set completeopt+=noselect") -vim.lsp.enable({ "lua_ls", "gh_actions_ls", "gopls", "astro", "nixd", "zls", "ruff", "tflint", "just", "ty", "templ" }) +vim.lsp.enable({ + "lua_ls", + "gh_actions_ls", + "gopls", + "astro", + "nixd", + "zls", + "ruff", + "tflint", + "just", + "ty", + "templ", + "terraformls", +}) vim.api.nvim_create_autocmd("LspAttach", { callback = function(ev) local client = vim.lsp.get_client_by_id(ev.data.client_id) diff --git a/lsp/terraformls.lua b/lsp/terraformls.lua index 4832dce..90a9cfa 100644 --- a/lsp/terraformls.lua +++ b/lsp/terraformls.lua @@ -1,7 +1,22 @@ +---@brief +--- https://github.com/hashicorp/terraform-ls + +---@type vim.lsp.Config return { - settings = { + cmd = { "terraform-ls", "serve" }, + filetypes = { "terraform", "terraform-vars" }, + root_markers = { ".terraform", ".git" }, + init_options = { terraform = { path = "/etc/profiles/per-user/ethan/bin/tofu", }, }, + capabilities = { + experimental = { + showReferencesCommandId = "client.showReferences", + }, + }, + on_attach = function(_, bufnr) + vim.lsp.codelens.enable(true, { bufnr = bufnr }) + end, } -- 2.51.2