LazyVim.LazyVim/lua/lazyvim/plugins/extras/lang/terraform.lua
EJ 94b4219327
fix(extras): lazy-load telescope-terraform plugins (#4667)
## Description

In the current terraform extra, both
`cappyzawa/telescope-terraform.nvim` and
`ANGkeith/telescope-terraform-doc.nvim` are dependencies of
`telescope.nvim`.
This should be reversed so that the telescope extensions only load when
needed
(I added a `ft` trigger which I think makes the most sense), and not as
a
dependency of `telescope.nvim`.

## Related Issue(s)

No related issues, just fixed this when the loading time of
`telescope-terraform-doc.nvim` in-particular was annoying (+~30ms
startup).

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2024-11-08 21:08:21 +01:00

82 lines
1.8 KiB
Lua

return {
recommended = function()
return LazyVim.extras.wants({
ft = { "terraform", "hcl" },
root = ".terraform",
})
end,
{
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "terraform", "hcl" } },
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
terraformls = {},
},
},
},
-- ensure terraform tools are installed
{
"williamboman/mason.nvim",
opts = { ensure_installed = { "tflint" } },
},
{
"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.terraform_fmt,
null_ls.builtins.diagnostics.terraform_validate,
})
end,
},
{
"mfussenegger/nvim-lint",
optional = true,
opts = {
linters_by_ft = {
terraform = { "terraform_validate" },
tf = { "terraform_validate" },
},
},
},
{
"stevearc/conform.nvim",
optional = true,
opts = {
formatters_by_ft = {
terraform = { "terraform_fmt" },
tf = { "terraform_fmt" },
["terraform-vars"] = { "terraform_fmt" },
},
},
},
{
"nvim-telescope/telescope.nvim",
optional = true,
specs = {
{
"ANGkeith/telescope-terraform-doc.nvim",
ft = { "terraform", "hcl" },
config = function()
LazyVim.on_load("telescope.nvim", function()
require("telescope").load_extension("terraform_doc")
end)
end,
},
{
"cappyzawa/telescope-terraform.nvim",
ft = { "terraform", "hcl" },
config = function()
LazyVim.on_load("telescope.nvim", function()
require("telescope").load_extension("terraform")
end)
end,
},
},
},
}