aboutsummaryrefslogtreecommitdiff
path: root/plugins/settings.lua
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-05-24 17:04:16 -0400
committerjgmdev <jgmdev@gmail.com>2022-05-24 17:04:16 -0400
commitc1f3671e2a8defbc67d1e77c72d5866f2825cdb5 (patch)
treef64e320558e18242174fe15f0da4df5ddba7f13c /plugins/settings.lua
parent52092cc5d7c04ec32d89b1e398deaa11aeb145a3 (diff)
downloadlite-xl-plugins-c1f3671e2a8defbc67d1e77c72d5866f2825cdb5.tar.gz
lite-xl-plugins-c1f3671e2a8defbc67d1e77c72d5866f2825cdb5.zip
settings: load config_spec of plugins enabled after startup
Diffstat (limited to 'plugins/settings.lua')
-rw-r--r--plugins/settings.lua12
1 files changed, 11 insertions, 1 deletions
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]