From e0641d0cb2e39c9c85bcad99cc60764ea7df25f7 Mon Sep 17 00:00:00 2001 From: Saiful Islam Date: Fri, 31 May 2024 16:16:54 +0600 Subject: [PATCH] update (MasonInstallAll): install package only if it's missing (#2864) The ```MasonInstallAll``` command was installing all packages every time when run ```MasonInstallAll``` command. But we can make it like that so It will install only missing package not all. I think this is better approach. Anyway, Thanks for great work. --- lua/nvchad/plugins/init.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/nvchad/plugins/init.lua b/lua/nvchad/plugins/init.lua index 3ebafe1..0d96609 100644 --- a/lua/nvchad/plugins/init.lua +++ b/lua/nvchad/plugins/init.lua @@ -55,9 +55,12 @@ return { require("mason").setup(opts) -- custom nvchad cmd to install all mason binaries listed - vim.api.nvim_create_user_command("MasonInstallAll", function() + vim.api.nvim_create_user_command('MasonInstallAll', function() if opts.ensure_installed and #opts.ensure_installed > 0 then - vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " ")) + for _, tool in ipairs(opts.ensure_installed) do + local p = require('mason-registry').get_package(tool) + if not p:is_installed() then p:install() end + end end end, {})