Skip to content

Commit

Permalink
fix: opts setup error (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
arakkkkk authored Nov 30, 2024
1 parent 79df3e7 commit 0e1b248
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lua/mdeval.lua
Original file line number Diff line number Diff line change
Expand Up @@ -432,18 +432,19 @@ end

M.opts = defaults
function M.setup(opts)
-- Apply user-defined options with fallback to defaults.
if not opts then
return
end

-- Apply user-defined options, skipping tables and updating eval_options.
for k, v in pairs(opts) do
if type(v) ~= "table" then
M.opts[k] = v
end
end
for k, v in pairs(opts.eval_options) do
if M.opts.eval_options[k] == nil then
M.opts.eval_options[k] = {}
end
for nk, nv in pairs(v) do
M.opts.eval_options[k][nk] = nv
elseif k == "eval_options" then
M.opts.eval_options = M.opts.eval_options or {}
for nk, nv in pairs(v) do
M.opts.eval_options[nk] = nv
end
end
end
end
Expand Down

0 comments on commit 0e1b248

Please sign in to comment.