From 01ac6de9a938f5d9f5dda09d1a5aa5dd54a998a5 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Fri, 28 Apr 2023 09:56:43 -0400 Subject: [PATCH] fix(plugins): protect ensure_installed table from community packs --- plugins/mason.lua | 31 ++++++++++++++++++++++--------- plugins/treesitter.lua | 10 +++++++--- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/plugins/mason.lua b/plugins/mason.lua index 9018347..b202fef 100644 --- a/plugins/mason.lua +++ b/plugins/mason.lua @@ -4,23 +4,36 @@ return { { "williamboman/mason-lspconfig.nvim", -- overrides `require("mason-lspconfig").setup(...)` - opts = { - -- ensure_installed = { "lua_ls" }, - }, + opts = function(_, opts) + -- add more things to the ensure_installed table protecting against community packs modifying it + if not opts.ensure_installed then opts.ensure_installed = {} end + require("astronvim.utils").list_insert_unique(opts.ensure_installed, { + -- "lua_ls", + }) + end, }, -- use mason-null-ls to configure Formatters/Linter installation for null-ls sources { "jay-babu/mason-null-ls.nvim", -- overrides `require("mason-null-ls").setup(...)` - opts = { - -- ensure_installed = { "prettier", "stylua" }, - }, + opts = function(_, opts) + -- add more things to the ensure_installed table protecting against community packs modifying it + if not opts.ensure_installed then opts.ensure_installed = {} end + require("astronvim.utils").list_insert_unique(opts.ensure_installed, { + -- "prettier", + -- "stylua", + }) + end, }, { "jay-babu/mason-nvim-dap.nvim", -- overrides `require("mason-nvim-dap").setup(...)` - opts = { - -- ensure_installed = { "python" }, - }, + opts = function(_, opts) + -- add more things to the ensure_installed table protecting against community packs modifying it + if not opts.ensure_installed then opts.ensure_installed = {} end + require("astronvim.utils").list_insert_unique(opts.ensure_installed, { + -- "python", + }) + end, }, } diff --git a/plugins/treesitter.lua b/plugins/treesitter.lua index 092d7a8..acffc4e 100644 --- a/plugins/treesitter.lua +++ b/plugins/treesitter.lua @@ -1,6 +1,10 @@ return { "nvim-treesitter/nvim-treesitter", - opts = { - -- ensure_installed = { "lua" }, - }, + opts = function(_, opts) + -- add more things to the ensure_installed table protecting against community packs modifying it + if not opts.ensure_installed then opts.ensure_installed = {} end + require("astronvim.utils").list_insert_unique(opts.ensure_installed, { + -- "lua" + }) + end, }