feat(ui2): support routing "typed_cmd" trigger to target

Problem:  Unable to immediately open a typed command in the pager.
Solution: Support mapping msg_show "typed_cmd" trigger in
          cfg.msg.targets (e.g. `targets = { typed_cmd = 'pager' }`).
This commit is contained in:
Luuk van Baal
2026-03-04 14:51:21 +01:00
parent 97549ad7cf
commit 875212c5b3
3 changed files with 10 additions and 5 deletions

View File

@@ -5288,7 +5288,7 @@ To enable the experimental UI (default opts shown): >lua
---@type 'cmd'|'msg' Default message target, either in the
---cmdline or in a separate ephemeral message window.
---@type string|table<string, 'cmd'|'msg'|'pager'> Default message target
or table mapping |ui-messages| kinds to a target.
or table mapping |ui-messages| kinds and triggers to a target.
targets = 'cmd',
timeout = 4000, -- Time a message is visible in the message window.
},

View File

@@ -11,7 +11,7 @@
--- ---@type 'cmd'|'msg' Default message target, either in the
--- ---cmdline or in a separate ephemeral message window.
--- ---@type string|table<string, 'cmd'|'msg'|'pager'> Default message target
--- or table mapping |ui-messages| kinds to a target.
--- or table mapping |ui-messages| kinds and triggers to a target.
--- targets = 'cmd',
--- timeout = 4000, -- Time a message is visible in the message window.
--- },

View File

@@ -386,9 +386,14 @@ end
--@param history boolean
---@param append boolean
---@param id integer|string
function M.msg_show(kind, content, replace_last, _, append, id)
-- Set the entered search command in the cmdline (if available).
local tgt = kind == 'search_cmd' and 'cmd' or ui.cfg.msg.targets[kind] or ui.cfg.msg.target
---@param trigger string
function M.msg_show(kind, content, replace_last, _, append, id, trigger)
-- Set the entered search command in the cmdline (if available). Otherwise route
-- to configured target: 'trigger' takes precedence over 'kind.'
local tgt = kind == 'search_cmd' and 'cmd'
or ui.cfg.msg.targets[trigger]
or ui.cfg.msg.targets[kind]
or ui.cfg.msg.target
if kind == 'search_cmd' and ui.cmdheight == 0 then
-- Blocked by messaging() without ext_messages. TODO: look at other messaging() guards.
return