rm support for ooold plugin syntax

This commit is contained in:
siduck 2022-11-15 18:54:21 +05:30
parent cdbdd66929
commit 4971e07f6a

View File

@ -89,29 +89,14 @@ end
-- merge default/user plugin tables -- merge default/user plugin tables
M.merge_plugins = function(plugins) M.merge_plugins = function(plugins)
local plugin_configs = M.load_config().plugins local user_plugins = M.load_config().plugins
local user_plugins = plugin_configs plugins = merge_tb("force", plugins, M.load_config().plugins)
-- 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 final_table = {} local final_table = {}
for key, val in pairs(plugins) do for key, val in pairs(plugins) do
if val and type(val) == "table" then if val then
plugins[key] = val.rm_default_opts and user_plugins[key] or plugins[key] plugins[key] = (val.rm_default_opts and user_plugins[key]) or plugins[key]
plugins[key][1] = key plugins[key][1] = key
final_table[#final_table + 1] = plugins[key] final_table[#final_table + 1] = plugins[key]
end end
@ -122,27 +107,14 @@ end
-- override plugin options table with custom ones -- override plugin options table with custom ones
M.load_override = function(options_table, name) 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 if user_plugins[name] then
local user_override = plugin_configs.override and plugin_configs.override[name] plugin_options = user_plugins[name].override_options or {}
if user_override and type(user_override) == "table" then plugin_options = type(plugin_options) == "table" and plugin_options or plugin_options()
plugin_options = user_override
end 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) return merge_tb("force", options_table, plugin_options)
end end
@ -178,12 +150,6 @@ M.packer_sync = function(...)
if packer_exists then if packer_exists then
packer.sync(...) 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 else
error "Packer could not be loaded!" error "Packer could not be loaded!"
end end