vimtricks.wiki Concise Vim tricks, one at a time.

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 list
  • vim.ui.input(opts, on_confirm) — called whenever Neovim wants a single text input
  • Plugins like dressing.nvim or snacks.nvim monkey-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 opts table includes prompt and format_item fields
  • vim.ui.input overrides affect LSP rename, :substitute confirm, and any input() call

Next

How do I enable matchit so % jumps between if/else/end style pairs?