refactor: use lazy's new opts_extend functionality for treesitter and mason

This commit is contained in:
Folke Lemaitre 2024-06-07 09:03:59 +02:00
parent f70d350085
commit ab41ff551b
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
33 changed files with 54 additions and 219 deletions

View file

@ -7,11 +7,7 @@ return {
end, end,
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "ansible-lint" } },
opts.ensure_installed = opts.ensure_installed or {}
-- for ansiblels validation
vim.list_extend(opts.ensure_installed, { "ansible-lint" })
end,
}, },
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",

View file

@ -15,11 +15,7 @@ return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "astro" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "astro" })
end
end,
}, },
-- LSP Servers -- LSP Servers

View file

@ -16,11 +16,7 @@ return {
-- Add C/C++ to treesitter -- Add C/C++ to treesitter
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "cpp" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "cpp" })
end
end,
}, },
{ {
@ -120,11 +116,7 @@ return {
-- Ensure C/C++ debugger is installed -- Ensure C/C++ debugger is installed
"williamboman/mason.nvim", "williamboman/mason.nvim",
optional = true, optional = true,
opts = function(_, opts) opts = { ensure_installed = { "codelldb" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "codelldb" })
end
end,
}, },
opts = function() opts = function()
local dap = require("dap") local dap = require("dap")

View file

@ -7,11 +7,7 @@ return {
end, end,
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "cmake" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "cmake" })
end
end,
}, },
{ {
"nvimtools/none-ls.nvim", "nvimtools/none-ls.nvim",
@ -34,10 +30,7 @@ return {
}, },
{ {
"mason.nvim", "mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "cmakelang", "cmakelint" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "cmakelang", "cmakelint" })
end,
}, },
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",

View file

@ -7,18 +7,11 @@ return {
end, end,
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "dockerfile" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "dockerfile" })
end
end,
}, },
{ {
"mason.nvim", "mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "hadolint" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "hadolint" })
end,
}, },
{ {
"nvimtools/none-ls.nvim", "nvimtools/none-ls.nvim",

View file

@ -7,13 +7,7 @@ return {
end, end,
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "elixir", "heex", "eex" } },
vim.list_extend(opts.ensure_installed, {
"elixir",
"heex",
"eex",
})
end,
}, },
{ {
"nvim-neotest/neotest", "nvim-neotest/neotest",

View file

@ -6,19 +6,12 @@ return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "elm" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "elm" })
end
end,
}, },
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "elm-format" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "elm-format" })
end,
}, },
{ {

View file

@ -5,19 +5,13 @@ return {
-- Treesitter git support -- Treesitter git support
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "git_config", "gitcommit", "git_rebase", "gitignore", "gitattributes" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "git_config", "gitcommit", "git_rebase", "gitignore", "gitattributes" })
end,
}, },
{ {
"nvim-cmp", "nvim-cmp",
dependencies = { dependencies = {
{ { "petertriho/cmp-git", opts = {} },
"petertriho/cmp-git",
opts = {},
},
}, },
---@module 'cmp' ---@module 'cmp'
---@param opts cmp.ConfigSchema ---@param opts cmp.ConfigSchema

View file

@ -6,11 +6,7 @@ return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "gleam" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "gleam" })
end
end,
}, },
{ {

View file

@ -7,14 +7,7 @@ return {
end, end,
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "go", "gomod", "gowork", "gosum" } },
vim.list_extend(opts.ensure_installed, {
"go",
"gomod",
"gowork",
"gosum",
})
end,
}, },
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
@ -90,10 +83,7 @@ return {
-- Ensure Go tools are installed -- Ensure Go tools are installed
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "goimports", "gofumpt" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "goimports", "gofumpt" })
end,
}, },
{ {
"nvimtools/none-ls.nvim", "nvimtools/none-ls.nvim",
@ -101,10 +91,7 @@ return {
dependencies = { dependencies = {
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "gomodifytags", "impl" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl" })
end,
}, },
}, },
opts = function(_, opts) opts = function(_, opts)
@ -132,10 +119,7 @@ return {
dependencies = { dependencies = {
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "delve" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "delve" })
end,
}, },
{ {
"leoluz/nvim-dap-go", "leoluz/nvim-dap-go",

View file

@ -9,11 +9,7 @@ return {
-- Add Haskell to treesitter -- Add Haskell to treesitter
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "haskell" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "haskell" })
end
end,
}, },
{ {
@ -33,10 +29,7 @@ return {
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "haskell-language-server" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "haskell-language-server" })
end,
}, },
{ {
@ -45,10 +38,7 @@ return {
dependencies = { dependencies = {
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "haskell-debug-adapter" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "haskell-debug-adapter" })
end,
}, },
}, },
}, },

View file

@ -16,7 +16,11 @@ return {
}) })
end, end,
{ "towolf/vim-helm", ft = "helm" }, {
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "helm" } },
},
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
opts = { opts = {

View file

@ -33,10 +33,7 @@ return {
-- Add java to treesitter. -- Add java to treesitter.
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "java" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "java" })
end,
}, },
-- Ensure java debugger and test packages are installed. -- Ensure java debugger and test packages are installed.
@ -46,10 +43,7 @@ return {
dependencies = { dependencies = {
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "java-debug-adapter", "java-test" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "java-test", "java-debug-adapter" })
end,
}, },
}, },
}, },

View file

@ -9,11 +9,7 @@ return {
-- add json to treesitter -- add json to treesitter
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "json5" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "json5" })
end
end,
}, },
-- yaml schema support -- yaml schema support

View file

@ -15,16 +15,12 @@ return {
-- Add packages(linting, debug adapter) -- Add packages(linting, debug adapter)
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "ktlint" } },
vim.list_extend(opts.ensure_installed or {}, { "ktlint" })
end,
}, },
-- Add syntax highlighting -- Add syntax highlighting
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "kotlin" } },
vim.list_extend(opts.ensure_installed or {}, { "kotlin" })
end,
}, },
-- Add language server -- Add language server
{ {

View file

@ -17,10 +17,7 @@ return {
}, },
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "markdownlint", "markdown-toc" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "markdownlint", "markdown-toc" })
end,
}, },
{ {
"nvimtools/none-ls.nvim", "nvimtools/none-ls.nvim",

View file

@ -5,10 +5,7 @@ return {
}, },
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "nix" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "nix" })
end,
}, },
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",

View file

@ -9,11 +9,7 @@ return {
{ "Hoffs/omnisharp-extended-lsp.nvim", lazy = true }, { "Hoffs/omnisharp-extended-lsp.nvim", lazy = true },
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "c_sharp" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "c_sharp" })
end
end,
}, },
{ {
"nvimtools/none-ls.nvim", "nvimtools/none-ls.nvim",
@ -41,11 +37,7 @@ return {
}, },
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "csharpier", "netcoredbg" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "netcoredbg", "csharpier" })
end
end,
}, },
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",

View file

@ -6,9 +6,7 @@ return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "php" } },
vim.list_extend(opts.ensure_installed, { "php" })
end,
}, },
{ {
@ -25,11 +23,7 @@ return {
optional = true, optional = true,
dependencies = { dependencies = {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "php-debug-adapter" } },
if type(opts.ensure_installed) == "table" then
table.insert(opts.ensure_installed, "php-debug-adapter")
end
end,
}, },
opts = function() opts = function()
local dap = require("dap") local dap = require("dap")

View file

@ -24,11 +24,7 @@ return {
end, end,
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "ninja", "rst" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "ninja", "rst" })
end
end,
}, },
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",

View file

@ -59,11 +59,7 @@ return {
}, },
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "r", "rnoweb" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "r", "rnoweb" })
end
end,
}, },
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",

View file

@ -7,11 +7,7 @@ return {
end, end,
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "ruby" } },
vim.list_extend(opts.ensure_installed, {
"ruby",
})
end,
}, },
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",

View file

@ -30,20 +30,14 @@ return {
-- Add Rust & related to treesitter -- Add Rust & related to treesitter
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "rust", "ron" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "ron", "rust" })
end,
}, },
-- Ensure Rust debugger is installed -- Ensure Rust debugger is installed
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
optional = true, optional = true,
opts = function(_, opts) opts = { ensure_installed = { "codelldb" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "codelldb" })
end,
}, },
{ {

View file

@ -7,11 +7,7 @@ return {
end, end,
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "scala" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "scala" })
end
end,
}, },
{ {
"scalameta/nvim-metals", "scalameta/nvim-metals",

View file

@ -67,11 +67,7 @@ return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
optional = true, optional = true,
opts = function(_, opts) opts = { ensure_installed = { "sql" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "sql" })
end
end,
}, },
-- Edgy integration -- Edgy integration
@ -99,10 +95,7 @@ return {
-- Linters & formatters -- Linters & formatters
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "sqlfluff" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "sqlfluff" })
end,
}, },
{ {
"mfussenegger/nvim-lint", "mfussenegger/nvim-lint",

View file

@ -15,11 +15,7 @@ return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "svelte" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "svelte" })
end
end,
}, },
-- LSP Servers -- LSP Servers

View file

@ -8,14 +8,7 @@ return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "terraform", "hcl" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, {
"terraform",
"hcl",
})
end
end,
}, },
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
@ -28,10 +21,7 @@ return {
-- ensure terraform tools are installed -- ensure terraform tools are installed
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "tflint" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "tflint" })
end,
}, },
{ {
"nvimtools/none-ls.nvim", "nvimtools/none-ls.nvim",

View file

@ -5,11 +5,7 @@ return {
}, },
{ {
"nvim-treesitter", "nvim-treesitter",
optional = true, opts = { ensure_installed = { "thrift" } },
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "thrift" })
end,
}, },
{ {
"nvim-lspconfig", "nvim-lspconfig",

View file

@ -11,11 +11,7 @@ return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = { ensure_installed = { "vue" } },
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "vue" })
end
end,
}, },
-- Add LSP servers -- Add LSP servers

View file

@ -19,10 +19,7 @@ return {
}, },
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = { ensure_installed = { "shellcheck" } },
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "shellcheck" })
end,
}, },
-- add some stuff to treesitter -- add some stuff to treesitter
{ {

View file

@ -3,6 +3,7 @@ return {
-- Ensure GitUI tool is installed -- Ensure GitUI tool is installed
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = { ensure_installed = { "gitui" } },
keys = { keys = {
{ {
"<leader>gG", "<leader>gG",
@ -30,9 +31,5 @@ return {
end, end,
}) })
end, end,
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "gitui" })
end,
}, },
} }

View file

@ -261,11 +261,11 @@ return {
cmd = "Mason", cmd = "Mason",
keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } }, keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
build = ":MasonUpdate", build = ":MasonUpdate",
opts_extend = { "ensure_installed" },
opts = { opts = {
ensure_installed = { ensure_installed = {
"stylua", "stylua",
"shfmt", "shfmt",
-- "flake8",
}, },
}, },
---@param opts MasonSettings | {ensure_installed: string[]} ---@param opts MasonSettings | {ensure_installed: string[]}

View file

@ -22,6 +22,7 @@ return {
{ "<c-space>", desc = "Increment Selection" }, { "<c-space>", desc = "Increment Selection" },
{ "<bs>", desc = "Decrement Selection", mode = "x" }, { "<bs>", desc = "Decrement Selection", mode = "x" },
}, },
opts_extend = { "ensure_installed" },
---@type TSConfig ---@type TSConfig
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
opts = { opts = {