summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/_extui/shared.lua
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2025-06-27 15:54:32 +0200
committerGitHub <noreply@github.com>2025-06-27 15:54:32 +0200
commitbfe42c84de053abe125f7a61116bc8a97ec32cde (patch)
tree6c02eccd6a5b3634b79e502ec23f7fad0aec2fe6 /runtime/lua/vim/_extui/shared.lua
parent64753b5c37cf9d0d3aa2ced068d749cdab43e250 (diff)
perf(extui): delay creating windows, buffers and parser (#34665)
Problem: vim._extui unconditionally creates windows, buffers and the Vimscript cmdline highlighter when it is first loaded. Solution: Schedule first creation of the window so that first redraw happens sooner (still need to create at least the cmdline window asap as it can have a different highlight through hl-MsgArea; thus further delaying until the first event that needs a particular target seems redundant). Load the cmdline highlighter on the first cmdline_show event.
Diffstat (limited to 'runtime/lua/vim/_extui/shared.lua')
-rw-r--r--runtime/lua/vim/_extui/shared.lua18
1 files changed, 5 insertions, 13 deletions
diff --git a/runtime/lua/vim/_extui/shared.lua b/runtime/lua/vim/_extui/shared.lua
index 0045748039..9454653c58 100644
--- a/runtime/lua/vim/_extui/shared.lua
+++ b/runtime/lua/vim/_extui/shared.lua
@@ -1,10 +1,10 @@
-local api, o = vim.api, vim.o
+local api = vim.api
local M = {
msg = nil, ---@type vim._extui.messages
cmd = nil, ---@type vim._extui.cmdline
ns = api.nvim_create_namespace('nvim._ext_ui'),
augroup = api.nvim_create_augroup('nvim._ext_ui', {}),
- cmdheight = -1, -- 'cmdheight' option value set by user.
+ cmdheight = 1, -- 'cmdheight' option value set by user.
wins = { cmd = -1, dialog = -1, msg = -1, pager = -1 },
bufs = { cmd = -1, dialog = -1, msg = -1, pager = -1 },
cfg = {
@@ -28,18 +28,13 @@ local wincfg = { -- Default cfg for nvim_open_win().
}
local tab = 0
---- Ensure the various buffers and windows have not been deleted.
-function M.tab_check_wins()
+---Ensure target buffers and windows are still valid.
+function M.check_targets()
local curtab = api.nvim_get_current_tabpage()
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)
- if type == 'cmd' then
- -- Attach highlighter to the cmdline buffer.
- local parser = assert(vim.treesitter.get_parser(M.bufs.cmd, 'vim', {}))
- M.cmd.highlighter = vim.treesitter.highlighter.new(parser)
- end
end
if
@@ -47,15 +42,12 @@ function M.tab_check_wins()
or not api.nvim_win_is_valid(M.wins[type])
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 == 'pager' or type == 'dialog') and { '', top, '', '', '', '', '', '' }
local cfg = vim.tbl_deep_extend('force', wincfg, {
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 == 'pager' and 'Pager' or nil,
- border = type == 'msg' and 'single' or border or 'none',
+ border = type == 'msg' and 'single' 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,