dotfiles bugabingas dorkfiles
owned by bugabinga
README Source History Refs Compare Notes Search fix(cmdline): strip leading firstc from cmdline info for format detection 998bbe5336edab323028aede255c0f08b20fd521
Oliver Jan Krylow <oliver@bugabinga.net > · 15 Apr 2026
unsigned
Browse files Compare with HEAD
The nvim_get_cmdline_info() returns cmdline chunks including firstc
(e.g. {":", "h"}), but format.detect patterns expect content without
firstc (e.g. "h"). Strip the leading firstc before comparing text
and detecting format changes.
Changed files (1) neovim/lua/bugabinga/cmdline/render.lua Modified 16 17 local BORDER_HIGHLIGHT_MAP
= {
76 77 function M.
show (cmdline_state)
77 78 local text
= cmdline_state:text()
78 80 local fmt
= format.detect(cmdline_state.firstc, text, cmdline_state.prompt)
79 81 state.current_fmt
= fmt
80 82 local display_text
= ' ' .. text
.. ' ' 127 129 state.window
= - 1 128 130 state.current_fmt
= nil 129 132 position.set_cmdline_anchor(
nil )
130 133 vim.g.ui_cmdline_pos
= nil 137 140 local info
= vim.api.nvim_get_cmdline_info()
138 - local text
= info.cmdline
and # info.cmdline
> 0 and table .
concat (info.cmdline,
'' )
or '' 141 + local raw
= info.cmdline
and # info.cmdline
> 0 and table .
concat (info.cmdline,
'' )
or '' 139 142 local firstc
= info.firstc
and info.firstc
~= '' and info.firstc
or '' 140 - local fmt
= format.detect(firstc, text, cmdline_state.prompt)
141 - if fmt.type
~= state.current_fmt.type
then 142 - state.current_fmt
= fmt
143 - vim.wo[state.window].winhighlight
= get_winhighlight(fmt.type)
144 - vim.api.nvim_buf_clear_namespace(state.buffer, ns,
0 ,
- 1 )
145 - local icon_hl
= ICON_HIGHLIGHT_MAP[fmt.type]
or 'CmdlineIconCmdline' 146 - vim.api.nvim_buf_set_extmark(state.buffer, ns,
0 ,
0 , {
147 - virt_text = { { fmt.icon, icon_hl } },
148 - virt_text_pos =
'overlay' ,
143 + local content
= raw
144 + if firstc
~= '' and raw:find(
'^' .. firstc)
then 145 + content
= raw:sub(
# firstc
+ 1 )
147 + if content
~= state.text
then 148 + state.text
= content
149 + local fmt
= format.detect(firstc, content, cmdline_state.prompt)
150 + if fmt.type
~= state.current_fmt.type
then 151 + state.current_fmt
= fmt
152 + vim.wo[state.window].winhighlight
= get_winhighlight(fmt.type)
153 + vim.api.nvim_buf_clear_namespace(state.buffer, ns,
0 ,
- 1 )
154 + local icon_hl
= ICON_HIGHLIGHT_MAP[fmt.type]
or 'CmdlineIconCmdline' 155 + vim.api.nvim_buf_set_extmark(state.buffer, ns,
0 ,
0 , {
156 + virt_text = { { fmt.icon, icon_hl } },
157 + virt_text_pos =
'overlay' ,
151 161 local cursor_byte
= cmdline_state:cursor_byte()
152 162 local cursor_col
= 2 + cursor_byte