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.lua | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'runtime/lua/vim/_extui.lua') diff --git a/runtime/lua/vim/_extui.lua b/runtime/lua/vim/_extui.lua index 8b3f67076e..99a3dfa307 100644 --- a/runtime/lua/vim/_extui.lua +++ b/runtime/lua/vim/_extui.lua @@ -17,6 +17,19 @@ --- }, ---}) ---``` +--- +---There are four separate window types used by this interface: +---- "cmd": The cmdline window; also used for 'showcmd', 'showmode', 'ruler', and +--- messages if 'cmdheight' > 0. +---- "box": The message box window; used for messages when 'cmdheight' == 0. +---- "more": The more-prompt window; used for |:messages| and certain messages +--- that should be shown in full. +---- "prompt": The cmdline prompt window; used for prompt messages that expect +--- user input. +--- +---These four windows are assigned the "cmdline", "msgbox", "msgmore" and +---"msgprompt" 'filetype' respectively. Use a |FileType| autocommand to configure +---any local options for these windows and their respective buffers. local api = vim.api local ext = require('vim._extui.shared') @@ -90,24 +103,17 @@ function M.enable(opts) ext.msg.prev_msg = '' end ext.cmdheight = value - elseif name == 'termguicolors' then - -- 'termguicolors' toggled; add or remove border and set 'winblend' for box windows. - for _, tab in ipairs(api.nvim_list_tabpages()) do - api.nvim_win_set_config(ext.wins[tab].box, { border = value and 'none' or 'single' }) - vim.wo[ext.wins[tab].box].winblend = value and 30 or 0 - end end end if vim.v.vim_did_enter == 1 then ext.tab_check_wins() check_opt('cmdheight', vim.o.cmdheight) - check_opt('termguicolors', vim.o.termguicolors) end api.nvim_create_autocmd('OptionSet', { group = ext.augroup, - pattern = { 'cmdheight', 'termguicolors' }, + pattern = { 'cmdheight' }, callback = function(ev) ext.tab_check_wins() check_opt(ev.match, vim.v.option_new) @@ -122,7 +128,6 @@ function M.enable(opts) ext.tab_check_wins() if ev.event == 'VimEnter' then check_opt('cmdheight', vim.o.cmdheight) - check_opt('termguicolors', vim.o.termguicolors) end ext.msg.set_pos() end, -- cgit