refactor(mason): move ensure_installed to opts.ensure_installed

This commit is contained in:
Folke Lemaitre 2023-01-08 18:59:38 +01:00
parent 77b5e9ab56
commit 814c43a053
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -114,17 +114,22 @@ return {
"williamboman/mason.nvim",
cmd = "Mason",
keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
ensure_installed = {
"stylua",
"shellcheck",
"shfmt",
"flake8",
opts = {
ensure_installed = {
"stylua",
"shellcheck",
"shfmt",
"flake8",
},
},
---@param opts MasonSettings
config = function(self, opts)
---@param opts MasonSettings | {ensure_installed: string[]}
config = function(plugin, opts)
if plugin.ensure_installed then
require("lazyvim.util").deprecate("treesitter.ensure_installed", "treesitter.opts.ensure_installed")
end
require("mason").setup(opts)
local mr = require("mason-registry")
for _, tool in ipairs(self.ensure_installed) do
for _, tool in ipairs(opts.ensure_installed) do
local p = mr.get_package(tool)
if not p:is_installed() then
p:install()