Skip to content

Commit 9fa44d5

Browse files
author
Yosef BAYOUDE IZOUKA
committed
Select snacks picker element based on cursor position
When calling snacks picker, auto select the corresponding item, based on the cursor position on the buffer
1 parent 9ebc135 commit 9fa44d5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lua/aerial/snacks.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ M.pick_symbol = function(opts)
6060

6161
return ret
6262
end,
63+
on_show = function(picker)
64+
local closest_or_exact_symbol = bufdata.positions[bufdata.last_win].exact_symbol or bufdata.positions[bufdata.last_win].closest_symbol
65+
local currentIdx = closest_or_exact_symbol.idx
66+
picker.list.cursor = currentIdx
67+
end,
6368
}))
6469
end
6570

0 commit comments

Comments
 (0)