diff options
| author | theprimeagain <the.primeagen@gmail.com> | 2026-02-28 14:29:28 -0700 |
|---|---|---|
| committer | theprimeagain <the.primeagen@gmail.com> | 2026-02-28 14:29:49 -0700 |
| commit | 78f39f61606597ca778ec01e2058a3e652000d7e (patch) | |
| tree | 332ccb8a69a98d664854a7bbb99b297f6460d2d9 /lua/99/window/select-window.lua | |
| parent | d485196b0a7956e9efb9f73eccfb126b95d113b3 (diff) | |
| download | a4-78f39f61606597ca778ec01e2058a3e652000d7e.tar.xz a4-78f39f61606597ca778ec01e2058a3e652000d7e.zip | |
selection works nicely now
Diffstat (limited to 'lua/99/window/select-window.lua')
| -rw-r--r-- | lua/99/window/select-window.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lua/99/window/select-window.lua b/lua/99/window/select-window.lua new file mode 100644 index 0000000..3c90e0b --- /dev/null +++ b/lua/99/window/select-window.lua @@ -0,0 +1,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 |
