blob: 3c90e0be44aebbf805134087e2c688f6deeb6116 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
local Window = require("99.window")
--- @param lines string[]
---@param cb fun(idx: number): nil
local function select_window(lines, cb)
Window.capture_select_input("Select", {
content = lines,
keymap = {
enter = "select",
},
cb = function(success, result)
if not success or result == "" then
return
end
local idx = tonumber(vim.fn.matchstr(result, "^\\d\\+"))
if idx == nil then
return
end
local r = lines[idx]
if not r then
return
end
cb(idx)
end,
})
end
return select_window
|