From 302e59f734ec4d2e032b32e0134f6925c73d1f10 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Fri, 9 May 2025 14:47:36 +0200 Subject: feat(extui): assign 'filetype' to extui windows (#33924) Problem: Unable to discern windows used by the extui interface to configure their local options. 'winblend' may be detrimental to legibility depending on the colorscheme and 'background'. Solution: Assign the "cmdline", "msgmore", "msgprompt" and "msgbox" 'filetype' to the respective windows. Don't set 'winblend' for the message "box" window. --- runtime/lua/vim/_extui/shared.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'runtime/lua/vim/_extui/shared.lua') diff --git a/runtime/lua/vim/_extui/shared.lua b/runtime/lua/vim/_extui/shared.lua index 5c0910849e..76eb744135 100644 --- a/runtime/lua/vim/_extui/shared.lua +++ b/runtime/lua/vim/_extui/shared.lua @@ -47,7 +47,7 @@ function M.tab_check_wins() M.cmd.highlighter = vim.treesitter.highlighter.new(parser) elseif type == 'more' then -- Close more window with `q`, same as `checkhealth` - vim.keymap.set('n', 'q', 'c', { buffer = M.bufs.more }) + api.nvim_buf_set_keymap(M.bufs.more, 'n', 'q', 'c', {}) end end @@ -80,12 +80,15 @@ function M.tab_check_wins() end if setopt then - if type == 'box' and o.termguicolors then - vim.wo[M.wins[M.tab][type]].winblend = 30 - end - vim.wo[M.wins[M.tab][type]].linebreak = false - vim.wo[M.wins[M.tab][type]].smoothscroll = true - vim.wo[M.wins[M.tab][type]].eventignorewin = 'all' + -- Fire a FileType autocommand with window context to let the user reconfigure local options. + api.nvim_win_call(M.wins[M.tab][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 = type == 'cmd' and 'cmdline' or ('msg' .. type) + api.nvim_set_option_value('filetype', ft, { scope = 'local' }) + api.nvim_set_option_value('eventignorewin', 'all', { scope = 'local' }) + end) end end end -- cgit v1.3-3-g829e