From c1f3671e2a8defbc67d1e77c72d5866f2825cdb5 Mon Sep 17 00:00:00 2001 From: jgmdev Date: Tue, 24 May 2022 17:04:16 -0400 Subject: settings: load config_spec of plugins enabled after startup --- plugins/settings.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/settings.lua b/plugins/settings.lua index 9186d84..9ae29b2 100644 --- a/plugins/settings.lua +++ b/plugins/settings.lua @@ -99,7 +99,8 @@ settings.option = { ---@param section string ---@param options settings.option[] ---@param plugin_name? string Optional name of plugin -function settings.add(section, options, plugin_name) +---@param overwrite? boolean Overwrite previous section options +function settings.add(section, options, plugin_name, overwrite) local category = "" if plugin_name ~= nil then category = "plugins" @@ -107,6 +108,10 @@ function settings.add(section, options, plugin_name) category = "core" end + if overwrite and settings[category][section] then + settings[category][section] = {} + end + if not settings[category][section] then settings[category][section] = {} if category ~= "plugins" then @@ -1100,6 +1105,11 @@ function Settings:enable_plugin(plugin) require("plugins." .. plugin) + if config.plugins[plugin] and config.plugins[plugin].config_spec then + local conf = config.plugins[plugin].config_spec + settings.add(conf.name, conf, plugin, true) + end + for _, section in ipairs(settings.plugin_sections) do local plugins = settings.plugins[section] -- cgit v1.2.3