From 7b22b1712cf46db79b355c24f52c86d1bb705394 Mon Sep 17 00:00:00 2001 From: jgmdev Date: Mon, 23 May 2022 17:26:05 -0400 Subject: settings: added ability to scan for plugins config_spec. --- plugins/settings.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'plugins/settings.lua') 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() -- cgit v1.2.3