neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 56709ca1689a8e3e455f896e3ef78cfafe511d4a
parent a0a86fdc049a8e2b28537b0ec0b35c1c45289f2a
Author: Tomasz N <przepompownia@users.noreply.github.com>
Date:   Fri, 26 Sep 2025 03:51:14 +0200

fix(extui): setup buffers after activating `eventignorewin` (#35915)

fix(extui): set options and buffer name after 'eventignorewin'

Problem:  Setting up extui buffers emits OptionSet and BufFilePost events.
Solution: Set options and buffer name after 'eventignorewin'.
Diffstat:
Mruntime/lua/vim/_extui/shared.lua | 31++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/runtime/lua/vim/_extui/shared.lua b/runtime/lua/vim/_extui/shared.lua @@ -66,27 +66,20 @@ function M.check_targets() if setopt then local name = { cmd = 'Cmd', dialog = 'Dialog', msg = 'Msg', pager = 'Pager' } - api.nvim_buf_set_name(M.bufs[type], ('[%s]'):format(name[type])) - api.nvim_set_option_value('swapfile', false, { buf = M.bufs[type] }) - api.nvim_set_option_value('modifiable', true, { buf = M.bufs[type] }) - api.nvim_set_option_value('bufhidden', 'hide', { buf = M.bufs[type] }) - api.nvim_set_option_value('buftype', 'nofile', { buf = M.bufs[type] }) - if type == 'pager' then - -- Close pager with `q`, same as `checkhealth` - api.nvim_buf_set_keymap(M.bufs.pager, 'n', 'q', '<Cmd>wincmd c<CR>', {}) - elseif type == M.cfg.msg.target then - M.msg.prev_msg = '' -- Will no longer be visible. - end - -- Fire a FileType autocommand with window context to let the user reconfigure local options. + -- First set 'eventignorewin' to avoid firing OptionSet and BufFilePost. api.nvim_win_call(M.wins[type], function() - api.nvim_set_option_value('wrap', true, { scope = 'local' }) - api.nvim_set_option_value('linebreak', false, { scope = 'local' }) - api.nvim_set_option_value('smoothscroll', true, { scope = 'local' }) local ft = name[type]:sub(1, 1):lower() .. name[type]:sub(2) api.nvim_set_option_value('filetype', ft, { scope = 'local' }) local ignore = 'all' .. (type == 'pager' and ',-TextYankPost' or '') api.nvim_set_option_value('eventignorewin', ignore, { scope = 'local' }) + api.nvim_set_option_value('wrap', true, { scope = 'local' }) + api.nvim_set_option_value('linebreak', false, { scope = 'local' }) + api.nvim_set_option_value('smoothscroll', true, { scope = 'local' }) + api.nvim_set_option_value('swapfile', false, { scope = 'local' }) + api.nvim_set_option_value('modifiable', true, { scope = 'local' }) + api.nvim_set_option_value('bufhidden', 'hide', { scope = 'local' }) + api.nvim_set_option_value('buftype', 'nofile', { scope = 'local' }) if type ~= 'msg' then -- Use MsgArea and hide search highlighting in the cmdline window. local hl = 'Normal:MsgArea' @@ -94,6 +87,14 @@ function M.check_targets() api.nvim_set_option_value('winhighlight', hl, { scope = 'local' }) end end) + api.nvim_buf_set_name(M.bufs[type], ('[%s]'):format(name[type])) + + if type == 'pager' then + -- Close pager with `q`, same as `checkhealth` + api.nvim_buf_set_keymap(M.bufs.pager, 'n', 'q', '<Cmd>wincmd c<CR>', {}) + elseif type == M.cfg.msg.target then + M.msg.prev_msg = '' -- Will no longer be visible. + end end end tab = curtab