Added in new merge method, and run it on plugins. Also made it so plugin configs can be set anywhere, even if we don't know the plugin beforehand.

This commit is contained in:
Adam Harrison 2021-12-05 18:32:20 -05:00
parent 7e6d9df58d
commit 456126400a
4 changed files with 20 additions and 6 deletions

View File

@ -17,6 +17,14 @@ function common.clamp(n, lo, hi)
end end
function common.merge(a, b)
local t = {}
for k, v in pairs(a) do t[k] = v end
if b then for k, v in pairs(b) do t[k] = v end end
return t
end
function common.round(n) function common.round(n)
return n >= 0 and math.floor(n + 0.5) or math.ceil(n - 0.5) return n >= 0 and math.floor(n + 0.5) or math.ceil(n - 0.5)
end end

View File

@ -30,10 +30,16 @@ config.borderless = false
config.tab_close_button = true config.tab_close_button = true
config.max_clicks = 3 config.max_clicks = 3
-- Disable plugin loading setting to false the config entry
-- of the same name.
config.plugins = {} config.plugins = {}
-- Allow you to set plugin configs even if we haven't seen the plugin before.
setmetatable(config.plugins, {
__index = function(t, k)
if rawget(t, k) == nil then rawset(t, k, {}) end
return rawget(t, k)
end
})
-- Disable these plugins by default.
config.plugins.trimwhitespace = false config.plugins.trimwhitespace = false
config.plugins.lineguide = false config.plugins.lineguide = false
config.plugins.drawwhitespace = false config.plugins.drawwhitespace = false

View File

@ -10,14 +10,14 @@ local RootView = require "core.rootview"
local DocView = require "core.docview" local DocView = require "core.docview"
local Doc = require "core.doc" local Doc = require "core.doc"
config.plugins.autocomplete = { config.plugins.autocomplete = common.merge({
-- Amount of characters that need to be written for autocomplete -- Amount of characters that need to be written for autocomplete
min_len = 3, min_len = 3,
-- The max amount of visible items -- The max amount of visible items
max_height = 6, max_height = 6,
-- The max amount of scrollable items -- The max amount of scrollable items
max_suggestions = 100, max_suggestions = 100,
} }, config.plugins.autocomplete)
local autocomplete = {} local autocomplete = {}

View File

@ -8,10 +8,10 @@ local style = require "core.style"
local RootView = require "core.rootview" local RootView = require "core.rootview"
local CommandView = require "core.commandview" local CommandView = require "core.commandview"
config.plugins.scale = { config.plugins.scale = common.merge({
mode = "code", mode = "code",
use_mousewheel = true use_mousewheel = true
} }, config.plugins.scale)
local scale_steps = 0.05 local scale_steps = 0.05