fix: more robust defaults

This commit is contained in:
Jan K9f 2025-07-28 19:48:29 +02:00
commit 383c098548
Signed by: jank
GPG key ID: 22BEAC760B3333D6

View file

@ -1,6 +1,8 @@
local M = {} local M = {}
M.options = { M.options = {}
local defaults = {
hotkey = "<leader>tq", hotkey = "<leader>tq",
quote_chars = { "'", '"', "`" }, quote_chars = { "'", '"', "`" },
} }
@ -8,13 +10,7 @@ M.options = {
---Merges user-provided options with default options. ---Merges user-provided options with default options.
---@param user_options table|nil User-provided options ---@param user_options table|nil User-provided options
function M.setup(user_options) function M.setup(user_options)
if user_options and type(user_options) == "table" then M.options = vim.tbl_deep_extend("force", {}, defaults, user_options or {})
for k, v in pairs(user_options) do
if v ~= nil then
M.options[k] = v
end
end
end
local map_opts = { local map_opts = {
desc = "Swaps the quotes around", desc = "Swaps the quotes around",