aboutsummaryrefslogtreecommitdiff
path: root/plugins/settings.lua
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-05-23 17:26:05 -0400
committerjgmdev <jgmdev@gmail.com>2022-05-23 17:49:43 -0400
commit7b22b1712cf46db79b355c24f52c86d1bb705394 (patch)
tree7d45dddfcac5e37c822617b099beb00470f149fd /plugins/settings.lua
parent21025951770df69c0fedd67b33f1f7725c22980d (diff)
downloadlite-xl-plugins-7b22b1712cf46db79b355c24f52c86d1bb705394.tar.gz
lite-xl-plugins-7b22b1712cf46db79b355c24f52c86d1bb705394.zip
settings: added ability to scan for plugins config_spec.
Diffstat (limited to 'plugins/settings.lua')
-rw-r--r--plugins/settings.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/settings.lua b/plugins/settings.lua
index f304f9a..3471ad2 100644
--- a/plugins/settings.lua
+++ b/plugins/settings.lua
@@ -779,6 +779,19 @@ local function merge_settings()
end
end
+---Scan all plugins to check if they define a config_spec and load it.
+local function scan_plugins_spec()
+ for plugin, conf in pairs(config.plugins) do
+ if type(conf) == "table" and conf.config_spec then
+ settings.add(
+ conf.config_spec.name,
+ conf.config_spec,
+ plugin
+ )
+ end
+ end
+end
+
---Called at core first run to store the default keybindings.
local function store_default_keybindings()
for name, _ in pairs(command.map) do
@@ -858,6 +871,10 @@ local function add_control(pane, option, plugin_name)
---@type widget
local widget = nil
+ if type(option.type) == "string" then
+ option.type = settings.type[option.type:upper()]
+ end
+
if option.type == settings.type.NUMBER then
---@type widget.label
Label(pane, option.label .. ":")
@@ -1373,6 +1390,9 @@ function core.run()
-- merge custom settings into config
merge_settings()
+ -- append all settings defined in the plugins spec
+ scan_plugins_spec()
+
---@type settings.ui
settings.ui = Settings()