How do I override Neovim's default selection and input dialogs so plugins like Telescope or FZF handle them automatically?
Answer
vim.ui.select()
Explanation
Neovim exposes vim.ui.select() and vim.ui.input() as overridable hooks. Any plugin — or your own init.lua — can replace them with a custom implementation, so every part of Neovim that needs a selection list or a text prompt automatically uses your preferred UI.
How it works
vim.ui.select(items, opts, on_choice)— called whenever Neovim wants the user to pick from a listvim.ui.input(opts, on_confirm)— called whenever Neovim wants a single text input- Plugins like
dressing.nvimorsnacks.nvimmonkey-patch these at startup, so all callers (LSP code actions, rename prompts, etc.) automatically use Telescope, FZF, or a styled float
Example
Minimal override that wraps selection in a floating list:
-- in your init.lua
vim.ui.select = function(items, opts, on_choice)
-- delegate to vim.fn.inputlist or a custom picker
local choices = {}
for i, item in ipairs(items) do
choices[i] = string.format('%d. %s', i, tostring(item))
end
local idx = vim.fn.inputlist(choices)
on_choice(idx > 0 and items[idx] or nil, idx > 0 and idx or nil)
end
With dressing.nvim installed, no manual override is needed — it patches vim.ui automatically.
Tips
- Always restore the original if your override fails to avoid breaking other plugins
- The
optstable includespromptandformat_itemfields vim.ui.inputoverrides affect LSP rename,:substituteconfirm, and anyinput()call