From 1f73ef0ec68ad065ebf12327a1ca60dd9a99006a Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 31 Jan 2022 14:13:51 +0530 Subject: [PATCH] clean remove_default_plugins function --- lua/core/utils.lua | 21 +++++++++------------ lua/plugins/init.lua | 2 ++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lua/core/utils.lua b/lua/core/utils.lua index 2099817..855e4eb 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -282,24 +282,21 @@ end M.remove_default_plugins = function(plugin_table) local removals = require("core.utils").load_config().plugins.default_plugin_remove or {} + local result = {} + if vim.tbl_isempty(removals) then return plugin_table end - local newtable = {} - local i = 1 - for _, value in ipairs(plugin_table) do - local removed = false - for _, removal in ipairs(removals) do - if value[1] == removal then - removed = true + + for _, value in pairs(plugin_table) do + for _, plugin in ipairs(removals) do + if value[1] ~= plugin then + table.insert(result, value) end end - if not removed then - newtable[i] = value - i = i + 1 - end end - return newtable + + return result end return M diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 3323d70..67de5ac 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -228,8 +228,10 @@ local plugins = { } --remove plugins specified in chadrc plugins = require("core.utils").remove_default_plugins(plugins) + -- append user plugins to default plugins local user_Plugins = plugin_settings.install + if type(user_Plugins) == "table" then if table.maxn(user_Plugins) == 1 then plugins[#plugins + 1] = user_Plugins[1]