dotfiles
bugabingas dorkfiles
owned by bugabinga
fix(cmdline): update border highlight when format changes
336f853d4d28bdd48036a9ee65416b16f9d092bb
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Use nvim_get_cmdline_info() in update_cursor to re-detect format
and update winhighlight when type changes (e.g. : → :!)
Changed files (1)
neovim/lua/bugabinga/cmdline/render.lua
Modified 2 2 local format
= require 'bugabinga.cmdline.format' 3 3 local position
= require 'bugabinga.cmdline.position' 4 4 local cursor
= require 'bugabinga.cmdline.cursor' 5 5 local highlight
= require 'bugabinga.cmdline.highlight' 6 +local table = require 'std.table' 7 8 local ns
= vim.api.nvim_create_namespace
'bugabinga.cmdline' 8 9 local hl_ns
= vim.api.nvim_create_namespace
'bugabinga.cmdline.hl' 133 134 if not vim.api.nvim_win_is_valid(state.window)
then 137 + local info
= vim.api.nvim_get_cmdline_info()
138 + local text
= info.cmdline
and #info.cmdline
> 0 and table.
concat(info.cmdline,
'')
or '' 139 + 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',
136 151 local cursor_byte
= cmdline_state:cursor_byte()
137 152 local cursor_col
= 2 + cursor_byte
138 153 local anchor
= position.get_cmdline_anchor()