rm support for ooold plugin syntax
This commit is contained in:
parent
cdbdd66929
commit
4971e07f6a
|
@ -89,29 +89,14 @@ end
|
|||
|
||||
-- merge default/user plugin tables
|
||||
M.merge_plugins = function(plugins)
|
||||
local plugin_configs = M.load_config().plugins
|
||||
local user_plugins = plugin_configs
|
||||
|
||||
-- old plugin syntax for adding plugins
|
||||
if plugin_configs.user and type(plugin_configs.user) == "table" then
|
||||
user_plugins = plugin_configs.user
|
||||
end
|
||||
|
||||
-- support old plugin removal syntax
|
||||
local remove_plugins = plugin_configs.remove
|
||||
if type(remove_plugins) == "table" then
|
||||
for _, v in ipairs(remove_plugins) do
|
||||
plugins[v] = nil
|
||||
end
|
||||
end
|
||||
|
||||
plugins = merge_tb("force", plugins, user_plugins)
|
||||
local user_plugins = M.load_config().plugins
|
||||
plugins = merge_tb("force", plugins, M.load_config().plugins)
|
||||
|
||||
local final_table = {}
|
||||
|
||||
for key, val in pairs(plugins) do
|
||||
if val and type(val) == "table" then
|
||||
plugins[key] = val.rm_default_opts and user_plugins[key] or plugins[key]
|
||||
if val then
|
||||
plugins[key] = (val.rm_default_opts and user_plugins[key]) or plugins[key]
|
||||
plugins[key][1] = key
|
||||
final_table[#final_table + 1] = plugins[key]
|
||||
end
|
||||
|
@ -122,27 +107,14 @@ end
|
|||
|
||||
-- override plugin options table with custom ones
|
||||
M.load_override = function(options_table, name)
|
||||
local plugin_configs, plugin_options = M.load_config().plugins, nil
|
||||
local user_plugins = M.load_config().plugins
|
||||
local plugin_options = {}
|
||||
|
||||
-- support old plugin syntax for override
|
||||
local user_override = plugin_configs.override and plugin_configs.override[name]
|
||||
if user_override and type(user_override) == "table" then
|
||||
plugin_options = user_override
|
||||
if user_plugins[name] then
|
||||
plugin_options = user_plugins[name].override_options or {}
|
||||
plugin_options = type(plugin_options) == "table" and plugin_options or plugin_options()
|
||||
end
|
||||
|
||||
-- if no old style plugin override is found, then use the new syntax
|
||||
if not plugin_options and plugin_configs[name] then
|
||||
local override_options = plugin_configs[name].override_options or {}
|
||||
if type(override_options) == "table" then
|
||||
plugin_options = override_options
|
||||
elseif type(override_options) == "function" then
|
||||
plugin_options = override_options()
|
||||
end
|
||||
end
|
||||
|
||||
-- make sure the plugin options are a table
|
||||
plugin_options = type(plugin_options) == "table" and plugin_options or {}
|
||||
|
||||
return merge_tb("force", options_table, plugin_options)
|
||||
end
|
||||
|
||||
|
@ -178,12 +150,6 @@ M.packer_sync = function(...)
|
|||
|
||||
if packer_exists then
|
||||
packer.sync(...)
|
||||
|
||||
local plugins = M.load_config().plugins
|
||||
local old_style_options = plugins.user or plugins.override or plugins.remove
|
||||
if old_style_options then
|
||||
vim.notify_once("NvChad: This plugin syntax is deprecated, use new style config.", "Error")
|
||||
end
|
||||
else
|
||||
error "Packer could not be loaded!"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue