fix(ui2): allow empty argument for enable() #38605

Problem: `vim._core.ui2.enable` requires passing an empty table for
default options, unlike other (native) Lua API.

Solution: Initialize `opts` with empty table if `nil` is passed.
(cherry picked from commit e508aa0fa8)
This commit is contained in:
Christian Clason
2026-03-30 18:47:02 +02:00
committed by github-actions[bot]
parent b924afb36b
commit d83141c0f2

View File

@@ -168,6 +168,7 @@ local scheduled_ui_callback = vim.schedule_wrap(ui_callback)
---@nodoc
function M.enable(opts)
opts = opts or {}
vim.validate('opts', opts, 'table', true)
M.cfg = vim.tbl_deep_extend('keep', opts, M.cfg)
M.cfg.msg.target = type(M.cfg.msg.targets) == 'string' and M.cfg.msg.targets or M.cfg.msg.target