From fa05865a311c3af8483ac448459e2ba39b874259 Mon Sep 17 00:00:00 2001 From: Harm-Jan Blok Date: Wed, 24 Dec 2025 11:06:06 +0100 Subject: [PATCH 1/2] feat(lang): add opentofu support --- lua/lazyvim/plugins/extras/lang/opentofu.lua | 57 ++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/lang/opentofu.lua diff --git a/lua/lazyvim/plugins/extras/lang/opentofu.lua b/lua/lazyvim/plugins/extras/lang/opentofu.lua new file mode 100644 index 00000000..d7ebc258 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/opentofu.lua @@ -0,0 +1,57 @@ +vim.filetype.add({ + extension = { + tofu = "opentofu", + }, +}) + +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "terraform", "hcl" }) + vim.treesitter.language.register("opentofu", "hcl") + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + tofu_ls = {}, + }, + }, + }, + { + "mason-org/mason.nvim", + opts = { ensure_installed = { "tofu-ls" } }, + }, + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local null_ls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + null_ls.builtins.formatting.opentofu_fmt, + null_ls.builtins.diagnostics.opentofu_validate, + }) + end, + }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + opentofu = { "tofu" }, + }, + }, + }, + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + opentofu = { "tofu_fmt" }, + }, + }, + }, +} From 5d8004c2f9d4ea44d27b9a74f57ff68606288992 Mon Sep 17 00:00:00 2001 From: Harm-Jan Blok Date: Wed, 24 Dec 2025 11:25:25 +0100 Subject: [PATCH 2/2] Add recommended; remove ensure_installed --- lua/lazyvim/plugins/extras/lang/opentofu.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/opentofu.lua b/lua/lazyvim/plugins/extras/lang/opentofu.lua index d7ebc258..cc7a9472 100644 --- a/lua/lazyvim/plugins/extras/lang/opentofu.lua +++ b/lua/lazyvim/plugins/extras/lang/opentofu.lua @@ -5,6 +5,13 @@ vim.filetype.add({ }) return { + recommended = function() + return LazyVim.extras.wants({ + ft = "hcl", + root = ".tofu", + }) + end, + { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) @@ -21,10 +28,6 @@ return { }, }, }, - { - "mason-org/mason.nvim", - opts = { ensure_installed = { "tofu-ls" } }, - }, { "nvimtools/none-ls.nvim", optional = true,