summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/_extui/cmdline.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/cmdline.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/cmdline.lua')
-rw-r--r--runtime/lua/vim/_extui/cmdline.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/lua/vim/_extui/cmdline.lua b/runtime/lua/vim/_extui/cmdline.lua
index 38050eb74f..c257d07ebb 100644
--- a/runtime/lua/vim/_extui/cmdline.lua
+++ b/runtime/lua/vim/_extui/cmdline.lua
@@ -30,7 +30,7 @@ local function win_config(win, hide, height)
end
end
-local cmdbuff ---@type string Stored cmdline used to calculate translation offset.
+local cmdbuff = '' ---@type string Stored cmdline used to calculate translation offset.
local promptlen = 0 -- Current length of the prompt, stored for use in "cmdline_pos"
--- Concatenate content chunks and set the text for the current row in the cmdline buffer.
---
@@ -57,6 +57,10 @@ end
---@param hl_id integer
function M.cmdline_show(content, pos, firstc, prompt, indent, level, hl_id)
M.level, M.indent, M.prompt = level, indent, M.prompt or #prompt > 0
+ if M.highlighter == nil then
+ local parser = assert(vim.treesitter.get_parser(ext.bufs.cmd, 'vim', {}))
+ M.highlighter = vim.treesitter.highlighter.new(parser)
+ end
-- Only enable TS highlighter for Ex commands (not search or filter commands).
M.highlighter.active[ext.bufs.cmd] = firstc == ':' and M.highlighter or nil
if ext.msg.cmd.msg_row ~= -1 then