dotfiles
bugabingas dorkfiles
owned by bugabinga
fix(cmdline): popupmenu scrollbar fixes and PmenuSbar/PmenuThumb styling
69cb39d044e28ba22d88595ff6846505188d65b1
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Popupmenu fixes:
- Track scrollbar position relative to visible viewport (top_idx)
- Fix buffer content refresh when scrolling past viewport edges
- Thumb stable while cycling within visible items, moves on page scroll
- Add top_idx state to track visible viewport position
PmenuSbar/PmenuThumb highlight groups:
- PmenuSbar: fg=ui_minor, bg=NormalFloat (track blends with popup bg)
- PmenuThumb: fg=ui_important_local, bg=NormalFloat (thumb stands out)
Changed files (2)
neovim/lua/bugabinga/cmdline/popupmenu.lua
Modified 16 16 format_type
= 'cmdline',
20 21 local function kind_icon(kind)
121 122 local selected
= state.selected
123 + local top_idx
= state.top_idx
123 125 if selected
< 0 then 126 - thumb_row
= math.
floor((height
- 1)
* selected
/ math.
max(
1, total
- 1))
128 + local relative
= selected
- top_idx
129 + thumb_row
= math.
max(
0,
math.
min(height
- 1, relative))
128 131 if state.above
then 129 132 thumb_row
= height
- 1 - thumb_row
146 149 local function apply_highlights(buf, items, lines, prefix)
147 150 for i
= 0,
#lines
- 1 do 148 - local item_idx
= state.above
and (
#items
- 1 - i)
or i
152 + if state.above
then 153 + item_idx
= state.top_idx
+ #lines
- 1 - i
155 + item_idx
= state.top_idx
+ i
149 157 local item
= items[item_idx
+ 1]
182 190 local pumheight
= vim.o.pumheight
183 191 local height
= pumheight
> 0 and math.
min(
#items, pumheight)
or #items
184 192 state.height
= height
193 + state.top_idx
= math.
max(
0,
math.
min(selected,
#items
- height))
185 194 local anchor
= get_anchor(row, col, grid, height)
186 195 local buf
= get_buf()
187 196 local win
= get_win(buf, anchor, width, height)
219 228 if not vim.api.nvim_win_is_valid(state.window)
then 222 - state.selected
= selected
223 - if selected
>= 0 and selected
< #state.items
then 224 - if state.above
then 225 - local reversed_idx
= #state.items
- 1 - selected
226 - vim.api.nvim_win_set_cursor(state.window, { reversed_idx
+ 1,
0 })
228 - vim.api.nvim_win_set_cursor(state.window, { selected
+ 1,
0 })
231 + local height
= state.height
232 + local total
= #state.items
233 + local old_top_idx
= state.top_idx
234 + if height
> 0 and total
> 0 then 235 + if selected
< state.top_idx
then 236 + state.top_idx
= math.
max(
0, selected)
237 + elseif selected
>= state.top_idx
+ height
then 238 + state.top_idx
= math.
min(selected, total
- height)
241 + state.selected
= selected
242 + if selected
>= 0 and total
> 0 then 244 + if state.above
then 245 + cursor_row
= (total
- 1 - selected)
- state.top_idx
+ 1 247 + cursor_row
= selected
- state.top_idx
+ 1 249 + cursor_row
= math.
max(
1,
math.
min(height, cursor_row))
250 + vim.api.nvim_win_set_cursor(state.window, { cursor_row,
0 })
231 252 if state.buffer
~= -1 and state.height
then 232 253 vim.api.nvim_buf_clear_namespace(state.buffer, ns,
0,
-1)
254 + if state.top_idx
~= old_top_idx
then 256 + for i
= state.top_idx,
math.
min(state.top_idx
+ height
- 1, total
- 1)
do 257 + table.
insert(visible, format_item(state.items[i
+ 1]))
259 + if state.above
then 260 + visible
= vim.iter(visible):rev():totable()
262 + vim.api.nvim_buf_set_lines(state.buffer,
0,
-1,
false, visible)
233 264 local lines
= vim.iter(state.items):map(
function(item)
234 265 return format_item(item)
255 286 state.above
= false 256 287 state.format_type
= 'cmdline' neovim/lua/bugabinga/nugu/init.lua
Modified145 145 _.Whitespace
= _.NonText
146 146 _.Pmenu
= _.NormalFloat
147 147 _.PmenuSel {
fg = ui_important_local,
sp = ui_important_local,
bg = _.Pmenu.bg,
bold =
true,
underline =
true }
148 -_.PmenuSbar {
bg = ui_unfocus }
149 -_.PmenuThumb {
bg = ui_minor }
148 +_.PmenuSbar {
fg = ui_minor,
bg = _.NormalFloat.bg }
149 +_.PmenuThumb {
fg = ui_important_local,
bg = _.NormalFloat.bg }
150 150 _.PmenuMatch {
fg = content_focus,
bold =
true }
151 151 _.PmenuMatchSel {
fg = content_focus,
bold =
true }
152 152 _.ComplMatchIns {
fg = content_accent }