Skip to content

Commit

Permalink
Move shims to config.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Robitaille committed Oct 29, 2024
1 parent b68c639 commit b18326b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
19 changes: 18 additions & 1 deletion lua/dressing/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,25 @@ local default_config = {

local M = vim.deepcopy(default_config)

-- Apply shims for backwards compatibility
---@param key string
---@param opts table
---@return table
M.apply_shim = function(key, opts)

-- Support start_in_insert for backwards compatibility.
if key == "input" and opts.start_in_insert ~= nil then
opts.start_mode = opts.start_in_insert and "insert" or "normal"
end

return opts
end

M.update = function(opts)
local newconf = vim.tbl_deep_extend("force", default_config, opts or {})

for k, v in pairs(newconf) do
M[k] = v
M[k] = M.apply_shim(k, v)
end
end

Expand All @@ -177,7 +191,10 @@ M.get_mod_config = function(key, ...)
if not M[key].get_config then
return M[key]
end

local conf = M[key].get_config(...)
conf = M.apply_shim(key, conf)

if conf then
return vim.tbl_deep_extend("force", M[key], conf)
else
Expand Down
5 changes: 0 additions & 5 deletions lua/dressing/input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,6 @@ local show_input = util.make_queued_async_fn(2, function(opts, on_confirm)

local start_mode = config.start_mode

-- Support start_in_insert for backwards compatibility.
if config.start_in_insert ~= nil then
start_mode = config.start_in_insert and "insert" or "normal"
end

local prompt = opts.prompt or config.default_prompt
local prompt_lines = vim.split(prompt, "\n", { plain = true, trimempty = true })

Expand Down

0 comments on commit b18326b

Please sign in to comment.