@@ -80,7 +80,7 @@ local function setup_window_autocmds(
80
80
end
81
81
end
82
82
83
- local function setup_hotkey_navigation (buf , config , line_to_hotkey )
83
+ local function setup_hotkey_navigation (buf , config , line_to_hotkey , handle_selection_cb )
84
84
if not (config .picker and config .picker .opts and config .picker .opts .hotkeys ) then
85
85
return
86
86
end
@@ -91,10 +91,17 @@ local function setup_hotkey_navigation(buf, config, line_to_hotkey)
91
91
end
92
92
93
93
local keymap_opts = { buffer = buf , nowait = true }
94
+ local auto_accept = config .picker and config .picker .opts and config .picker .opts .auto_accept
95
+ or false
96
+
94
97
for hotkey , line in pairs (hotkey_to_line ) do
95
98
local function jumpto ()
96
99
vim .api .nvim_win_set_cursor (vim .api .nvim_get_current_win (), { line , 0 })
100
+ if auto_accept then
101
+ handle_selection_cb ()
102
+ end
97
103
end
104
+
98
105
vim .keymap .set (" n" , hotkey , jumpto , keymap_opts )
99
106
if # hotkey == 1 then
100
107
vim .keymap .set (" n" , hotkey :upper (), jumpto , keymap_opts )
@@ -127,6 +134,8 @@ function M.create_main_window(
127
134
match_hl_kind
128
135
)
129
136
local keymaps = config .picker and config .picker .opts and config .picker .opts .keymaps or {}
137
+ local auto_accept = config .picker and config .picker .opts and config .picker .opts .auto_accept
138
+ or false
130
139
local preview_key = keymaps .preview or " K"
131
140
local close_key = keymaps .close or " q"
132
141
@@ -225,7 +234,7 @@ function M.create_main_window(
225
234
vim .keymap .set (" n" , preview_key , handle_preview , keymap_opts )
226
235
vim .keymap .set (" n" , close_key , close_window , keymap_opts )
227
236
228
- setup_hotkey_navigation (buf , config , line_to_hotkey )
237
+ setup_hotkey_navigation (buf , config , line_to_hotkey , handle_selection )
229
238
setup_window_autocmds (
230
239
buf ,
231
240
win ,
0 commit comments