Files
neovim/runtime/lua/vim/_core/ui.lua
T
Justin M. Keyes 55ceb314ca feat(ui): use vim.ui.select for :tselect, z= #39478
Problem:
`:tselect` and `z=` (spell suggest) have their own bespoke select menus.

Solution:
- Delegate to `vim.ui.select` instead.
- Bonus:
  - `:tselect` gains mouse support. `print_tag_list` didn't suport mouseclick.

This causes some minor regressions, which are not blockers:

- `z=` no longer draws the list right-left if 'rightleft' is set.
  - TODO: can/should `vim.ui.select` / `vim.fn.inputlist()` handle that?
- `:tselect`
  - No "column" headings (`# pri kind tag file`).
  - No highlighting: (HLF_T: tag name, HLF_D: file, HLF_CM: extra fields).
  - TODO: can `vim.ui.select()` support highlighted chunks (`[[text, hl_id], ...]`) ?

fix https://github.com/neovim/neovim/issues/25814
fix https://github.com/neovim/neovim/issues/31987
2026-04-28 18:29:17 -04:00

24 lines
751 B
Lua

local M = {}
--- Wait for |vim.ui.select()| and return the selected index. The default vim.ui.select impl
--- (inputlist()) is synchronous, but this also handles async pickers (fzf-lua, telescope, …).
---
--- @param items table Items to choose from.
--- @param opts table Forwarded to |vim.ui.select()|.
--- @return integer? # 1-based index of the chosen item, or nil if cancelled/interrupted.
function M.select_blocking(items, opts)
local choice ---@type integer?
local done = false
vim.ui.select(items, opts or {}, function(_, idx)
choice = idx
done = true
end)
-- vim.wait returns false on timeout (math.huge means never) or interrupt (-2).
vim.wait(math.huge, function()
return done
end)
return choice
end
return M