improve method of adding and removing plugins
This commit is contained in:
parent
a21e884983
commit
f81531df42
2 changed files with 33 additions and 23 deletions
|
@ -280,23 +280,35 @@ M.tbl_override_req = function(name, default_table)
|
|||
return vim.tbl_deep_extend("force", default_table, override)
|
||||
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
|
||||
--provide labels to plugins instead of integers
|
||||
M.label_plugins = function(plugins)
|
||||
plugins_labeled = {}
|
||||
for _, plugin in ipairs(plugins) do
|
||||
plugins_labeled[plugin[1]] = plugin
|
||||
end
|
||||
return plugins_labeled
|
||||
end
|
||||
|
||||
for _, value in pairs(plugin_table) do
|
||||
for _, plugin in ipairs(removals) do
|
||||
if value[1] ~= plugin then
|
||||
table.insert(result, value)
|
||||
end
|
||||
-- remove plugins specified by user from the plugins table
|
||||
M.remove_default_plugins = function(plugins)
|
||||
local removals = require("core.utils").load_config().plugins.default_plugin_remove or {}
|
||||
if not vim.tbl_isempty(removals) then
|
||||
for _, plugin in pairs(removals) do
|
||||
plugins[plugin] = nil
|
||||
end
|
||||
end
|
||||
return plugins
|
||||
end
|
||||
|
||||
return result
|
||||
-- append user plugins to default plugins
|
||||
M.add_user_plugins = function(plugins)
|
||||
local user_Plugins = require("core.utils").load_config().plugins.install or {}
|
||||
if not vim.tbl_isempty(user_Plugins) then
|
||||
for _, v in pairs(user_Plugins) do
|
||||
plugins[v[1]] = v
|
||||
end
|
||||
end
|
||||
return plugins
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue