robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
55ceb314ca
master
1local M ={} 2 3--- Wait for |vim.ui.select()| and return the selected index. The default vim.ui.select impl 4--- (inputlist()) is synchronous, but this also handles async pickers (fzf-lua, telescope, …). 5--- 6--- @param items table Items to choose from. 7--- @param opts table Forwarded to |vim.ui.select()|. 8--- @return integer? # 1-based index of the chosen item, or nil if cancelled/interrupted. 9function M . select_blocking ( items , opts ) 10local choice ---@type integer? 11local done =false 12vim . ui . select ( items , opts or {} , function ( _ , idx ) 13choice =idx 14done =true 15end ) 16-- vim.wait returns false on timeout (math.huge means never) or interrupt (-2). 17vim . wait ( math . huge , function () 18return done 19end ) 20return choice 21end 22 23return M