From e539310e6d5d61dddb8a6d15b2a853c1407a1f6c Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 13 Jul 2021 10:14:00 -0400 Subject: [PATCH] Namespace plugin-specific configuration settings. --- data/core/config.lua | 6 ++++-- data/core/init.lua | 2 +- data/plugins/autocomplete.lua | 4 ++-- data/plugins/scale.lua | 10 ++++++---- data/plugins/treeview.lua | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/data/core/config.lua b/data/core/config.lua index 777c190e..401ac0af 100644 --- a/data/core/config.lua +++ b/data/core/config.lua @@ -28,7 +28,9 @@ config.tab_close_button = true -- Disable plugin loading setting to false the config entry -- of the same name. -config.trimwhitespace = false -config.lineguide = false +config.plugins = {} + +config.plugins.trimwhitespace = false +config.plugins.lineguide = false return config diff --git a/data/core/init.lua b/data/core/init.lua index a23026b2..7a16ccae 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -712,7 +712,7 @@ function core.load_plugins() local ls = refused_list[root_dir == USERDIR and 'userdir' or 'datadir'].plugins ls[#ls + 1] = filename end - if version_match and config[basename] ~= false then + if version_match and config.plugins[basename] ~= false then local modname = "plugins." .. basename local ok = core.try(require, modname) if ok then core.log_quiet("Loaded plugin %q from %s", basename, plugin_dir) end diff --git a/data/plugins/autocomplete.lua b/data/plugins/autocomplete.lua index c76eed02..ce2d7ff1 100644 --- a/data/plugins/autocomplete.lua +++ b/data/plugins/autocomplete.lua @@ -9,7 +9,7 @@ local translate = require "core.doc.translate" local RootView = require "core.rootview" local DocView = require "core.docview" -config.autocomplete_max_suggestions = 6 +config.plugins.autocomplete = { max_suggestions = 6 } local autocomplete = {} autocomplete.map = {} @@ -129,7 +129,7 @@ local function update_suggestions() -- fuzzy match, remove duplicates and store items = common.fuzzy_match(items, partial) local j = 1 - for i = 1, config.autocomplete_max_suggestions do + for i = 1, config.autocomplete.max_suggestions do suggestions[i] = items[j] while items[j] and items[i].text == items[j].text do items[i].info = items[i].info or items[j].info diff --git a/data/plugins/scale.lua b/data/plugins/scale.lua index a5f5aaee..79152f8b 100644 --- a/data/plugins/scale.lua +++ b/data/plugins/scale.lua @@ -8,8 +8,10 @@ local style = require "core.style" local RootView = require "core.rootview" local CommandView = require "core.commandview" -config.scale_mode = "code" -config.scale_use_mousewheel = true +config.plugins.scale = { + mode = "code", + use_mousewheel = true +} local scale_level = 0 local scale_steps = 0.05 @@ -35,7 +37,7 @@ local function set_scale(scale) -- we set scale_level in case this was called by user scale_level = (scale - default_scale) / scale_steps - if config.scale_mode == "ui" then + if config.plugins.scale.mode == "ui" then SCALE = scale style.padding.x = style.padding.x * s @@ -68,7 +70,7 @@ end local on_mouse_wheel = RootView.on_mouse_wheel function RootView:on_mouse_wheel(d, ...) - if keymap.modkeys["ctrl"] and config.scale_use_mousewheel then + if keymap.modkeys["ctrl"] and config.plugins.scale.use_mousewheel then if d < 0 then command.perform "scale:decrease" end if d > 0 then command.perform "scale:increase" end else diff --git a/data/plugins/treeview.lua b/data/plugins/treeview.lua index 0b9304aa..14ada70f 100644 --- a/data/plugins/treeview.lua +++ b/data/plugins/treeview.lua @@ -358,7 +358,7 @@ local treeview_node = node:split("left", view, {x = true}, true) -- in the treeview node. local toolbar_view = nil local toolbar_plugin, ToolbarView = core.try(require, "plugins.toolbarview") -if config.toolbarview ~= false and toolbar_plugin then +if config.plugins.toolbarview ~= false and toolbar_plugin then toolbar_view = ToolbarView() treeview_node:split("down", toolbar_view, {y = true}) local min_toolbar_width = toolbar_view:get_min_width()