diff options
| author | Luuk van Baal <luukvbaal@gmail.com> | 2025-06-10 17:12:17 +0200 |
|---|---|---|
| committer | luukvbaal <luukvbaal@gmail.com> | 2025-06-13 14:28:01 +0200 |
| commit | 9ec6c19c674f959765956b54c8f5ef9a43c07e12 (patch) | |
| tree | c4652ede6ca398f2ce4d2883fc0368137734bb1d /runtime/lua/vim/_extui/shared.lua | |
| parent | 76f76fb0839100087093fe2d0897018193d526e4 (diff) | |
docs(extui): rename box->msg, more->pager, prompt->dialog
Includes breaking changes to the `opts` layout. "box" doesn't really
describe anything other than a floating window so was an unwanted synonym.
Diffstat (limited to 'runtime/lua/vim/_extui/shared.lua')
| -rw-r--r-- | runtime/lua/vim/_extui/shared.lua | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/runtime/lua/vim/_extui/shared.lua b/runtime/lua/vim/_extui/shared.lua index 8c50e82578..8fe494db48 100644 --- a/runtime/lua/vim/_extui/shared.lua +++ b/runtime/lua/vim/_extui/shared.lua @@ -5,17 +5,15 @@ local M = { ns = api.nvim_create_namespace('nvim._ext_ui'), augroup = api.nvim_create_augroup('nvim._ext_ui', {}), cmdheight = -1, -- 'cmdheight' option value set by user. - wins = { box = -1, cmd = -1, more = -1, prompt = -1 }, - bufs = { box = -1, cmd = -1, more = -1, prompt = -1 }, + wins = { cmd = -1, dialog = -1, msg = -1, pager = -1 }, + bufs = { cmd = -1, dialog = -1, msg = -1, pager = -1 }, cfg = { enable = true, msg = { -- Options related to the message module. - ---@type 'box'|'cmd' Type of window used to place messages, either in the - ---cmdline or in a separate ephemeral message box window. - pos = 'cmd', - box = { -- Options related to the message box window. - timeout = 4000, -- Time a message is visible. - }, + ---@type 'cmd'|'msg' Where to place regular messages, either in the + ---cmdline or in a separate ephemeral message window. + target = 'cmd', + timeout = 4000, -- Time a message is visible in the message window. }, }, } @@ -33,7 +31,7 @@ local tab = 0 --- Ensure the various buffers and windows have not been deleted. function M.tab_check_wins() local curtab = api.nvim_get_current_tabpage() - for _, type in ipairs({ 'box', 'cmd', 'more', 'prompt' }) do + for _, type in ipairs({ 'cmd', 'dialog', 'msg', 'pager' }) do local setopt = not api.nvim_buf_is_valid(M.bufs[type]) if setopt then M.bufs[type] = api.nvim_create_buf(false, true) @@ -50,16 +48,16 @@ function M.tab_check_wins() or not api.nvim_win_get_config(M.wins[type]).zindex -- no longer floating then local top = { vim.opt.fcs:get().horiz or o.ambw == 'single' and '─' or '-', 'WinSeparator' } - local border = (type == 'more' or type == 'prompt') and { '', top, '', '', '', '', '', '' } + local border = (type == 'pager' or type == 'dialog') and { '', top, '', '', '', '', '', '' } local cfg = vim.tbl_deep_extend('force', wincfg, { - focusable = type == 'more', + focusable = type == 'pager', mouse = type ~= 'cmd' and true or nil, anchor = type ~= 'cmd' and 'SE' or nil, hide = type ~= 'cmd' or M.cmdheight == 0 or nil, - title = type == 'more' and 'Messages' or nil, - border = type == 'box' and 'single' or border or 'none', - -- kZIndexMessages < zindex < kZIndexCmdlinePopupMenu (grid_defs.h), 'more' below others. - zindex = 200 - (type == 'more' and 1 or 0), + title = type == 'pager' and 'Pager' or nil, + border = type == 'msg' and 'single' or border or 'none', + -- kZIndexMessages < zindex < kZIndexCmdlinePopupMenu (grid_defs.h), pager below others. + zindex = 200 - (type == 'pager' and 1 or 0), _cmdline_offset = type == 'cmd' and 0 or nil, }) if tab ~= curtab and api.nvim_win_is_valid(M.wins[type]) then @@ -77,10 +75,11 @@ function M.tab_check_wins() end if setopt then - api.nvim_buf_set_name(M.bufs[type], 'nvim.' .. type) - if type == 'more' then - -- Close more window with `q`, same as `checkhealth` - api.nvim_buf_set_keymap(M.bufs.more, 'n', 'q', '<Cmd>wincmd c<CR>', {}) + local name = { cmd = 'Cmd', dialog = 'Dialog', msg = 'Msg', pager = 'Pager' } + 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>', {}) end -- Fire a FileType autocommand with window context to let the user reconfigure local options. @@ -88,9 +87,9 @@ function M.tab_check_wins() 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) + 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 == 'more' and ',-TextYankPost' or '') + local ignore = 'all' .. (type == 'pager' and ',-TextYankPost' or '') api.nvim_set_option_value('eventignorewin', ignore, { scope = 'local' }) end) end |
