clean remove_default_plugins function

This commit is contained in:
siduck 2022-01-31 14:13:51 +05:30
parent 6b06bb9ed4
commit 1f73ef0ec6
2 changed files with 11 additions and 12 deletions

View file

@ -282,24 +282,21 @@ end
M.remove_default_plugins = function(plugin_table) M.remove_default_plugins = function(plugin_table)
local removals = require("core.utils").load_config().plugins.default_plugin_remove or {} local removals = require("core.utils").load_config().plugins.default_plugin_remove or {}
local result = {}
if vim.tbl_isempty(removals) then if vim.tbl_isempty(removals) then
return plugin_table return plugin_table
end end
local newtable = {}
local i = 1 for _, value in pairs(plugin_table) do
for _, value in ipairs(plugin_table) do for _, plugin in ipairs(removals) do
local removed = false if value[1] ~= plugin then
for _, removal in ipairs(removals) do table.insert(result, value)
if value[1] == removal then
removed = true
end end
end end
if not removed then
newtable[i] = value
i = i + 1
end end
end
return newtable return result
end end
return M return M

View file

@ -228,8 +228,10 @@ local plugins = {
} }
--remove plugins specified in chadrc --remove plugins specified in chadrc
plugins = require("core.utils").remove_default_plugins(plugins) plugins = require("core.utils").remove_default_plugins(plugins)
-- append user plugins to default plugins -- append user plugins to default plugins
local user_Plugins = plugin_settings.install local user_Plugins = plugin_settings.install
if type(user_Plugins) == "table" then if type(user_Plugins) == "table" then
if table.maxn(user_Plugins) == 1 then if table.maxn(user_Plugins) == 1 then
plugins[#plugins + 1] = user_Plugins[1] plugins[#plugins + 1] = user_Plugins[1]