From 875212c5b3b879cd10bcd545e45de5293b2b3283 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 4 Mar 2026 14:51:21 +0100 Subject: [PATCH] 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' }`). --- runtime/doc/lua.txt | 2 +- runtime/lua/vim/_core/ui2.lua | 2 +- runtime/lua/vim/_core/ui2/messages.lua | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 989b038a1e..f9b386cee7 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -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 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. }, diff --git a/runtime/lua/vim/_core/ui2.lua b/runtime/lua/vim/_core/ui2.lua index b7ce79a76b..6766892f9b 100644 --- a/runtime/lua/vim/_core/ui2.lua +++ b/runtime/lua/vim/_core/ui2.lua @@ -11,7 +11,7 @@ --- ---@type 'cmd'|'msg' Default message target, either in the --- ---cmdline or in a separate ephemeral message window. --- ---@type string|table 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. --- }, diff --git a/runtime/lua/vim/_core/ui2/messages.lua b/runtime/lua/vim/_core/ui2/messages.lua index 1f946553c5..897b321728 100644 --- a/runtime/lua/vim/_core/ui2/messages.lua +++ b/runtime/lua/vim/_core/ui2/messages.lua @@ -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