Merge pull request #333 from adamharrison/namespace-config

Namespace plugin configs
This commit is contained in:
Adam 2021-07-15 17:58:51 -04:00 committed by GitHub
commit 0426fc26c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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.plugins.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

View File

@ -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

View File

@ -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()