From a4aa0417cf5553f8c154d5f6c92ab90a677542a3 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 17 Aug 2026 13:03:29 +0100 Subject: [PATCH] feat(ui2): drop default enter-pager-via-CR mapping #40993 --- runtime/doc/lua.txt | 5 +++++ runtime/doc/news.txt | 2 ++ runtime/lua/vim/_core/ui2.lua | 5 +++++ runtime/lua/vim/_core/ui2/messages.lua | 3 ++- test/functional/ui/messages2_spec.lua | 4 +++- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index a3356f407b..b2d89c8162 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -6123,6 +6123,7 @@ To enable this feature (default opts shown): >lua pager = { -- Options related to message window. height = 0.999, -- Maximum height. }, + pager_char = nil, -- Key checked after interactive messages. }, }) < @@ -6146,4 +6147,8 @@ indicates the spilled lines. To see the full messages, do either: to |Normal-mode|. • |g<| at any time. +If you'd like behavior similar to the old hit-enter prompt, pass +`pager_char = ""` on the `cfg` table. When the pager is shown, hitting +`` (in this example) will enter the pager. + vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl: diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 257d15a9dc..1e5523fba7 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -64,6 +64,8 @@ TREESITTER UI • Healthchecks for |vim.ui.img| were moved to `:checkhealth vim.health`. +• |ui2| messages pager no longer uses by default; use |g<| or set + the `pager_char` field when enabling ui2. VIMSCRIPT diff --git a/runtime/lua/vim/_core/ui2.lua b/runtime/lua/vim/_core/ui2.lua index 425251acfe..29412de3b3 100644 --- a/runtime/lua/vim/_core/ui2.lua +++ b/runtime/lua/vim/_core/ui2.lua @@ -28,6 +28,7 @@ --- pager = { -- Options related to message window. --- height = 0.999, -- Maximum height. --- }, +--- pager_char = nil, -- Key checked after interactive messages. --- }, --- }) --- ``` @@ -47,6 +48,10 @@ --- indicates the spilled lines. To see the full messages, do either: --- - ENTER immediately after interactive |:| cmdline shows a message and returns to |Normal-mode|. --- - |g<| at any time. +--- +--- If you'd like behavior similar to the old hit-enter prompt, pass `pager_char = ""` on +--- the `cfg` table. When the pager is shown, hitting `` (in this example) will enter the +--- pager. local api = vim.api local nvim_on = require('vim._core.util').nvim_on diff --git a/runtime/lua/vim/_core/ui2/messages.lua b/runtime/lua/vim/_core/ui2/messages.lua index 7abcd17e80..9178b7857f 100644 --- a/runtime/lua/vim/_core/ui2/messages.lua +++ b/runtime/lua/vim/_core/ui2/messages.lua @@ -597,7 +597,8 @@ local function cmd_on_key(key, typed) -- Check if window was entered and reopen with original config. A shown (but not entered) -- pager is dismissed instead; "g<" passes through to reopen and enter it. local can_enter = not api.nvim_get_mode().mode:match('[it]') and not pager_shown() - local enter = can_enter and (typed == '' or typed_g and (typed == '' or key == '<')) + local enter = can_enter + and (typed == ui.cfg.pager_char or typed_g and (typed == '' or key == '<')) or (typed:find('LeftMouse') and fn.getmousepos().winid == ui.wins.cmd) if enter then M.expand_msg('cmd', 'pager', true) diff --git a/test/functional/ui/messages2_spec.lua b/test/functional/ui/messages2_spec.lua index ea21a600a4..bb867306b9 100644 --- a/test/functional/ui/messages2_spec.lua +++ b/test/functional/ui/messages2_spec.lua @@ -188,7 +188,8 @@ describe('messages2', function() foo |*6 foo [+9] | ]]) - -- Do enter the pager in normal mode. + -- Do enter the pager in normal mode (with keybinding setup). + exec_lua([[require('vim._core.ui2').cfg.pager_char = '']]) command('nmap fclose') feed('') screen:expect([[ @@ -196,6 +197,7 @@ describe('messages2', function() foo |*12 1,1 Top| ]]) + exec_lua([[require('vim._core.ui2').cfg.pager_char = nil]]) -- Changing 'laststatus' reveals the global statusline with a pager height -- exceeding the available lines: #38008. command('set laststatus=3')