picker.nvim
picker.nvim is a highly customizable and extensible Neovim fuzzy finder plugin written in lua.


Features
- 15+ builtin sources.
- simple, fast fuzzy match engine powered by fzy.
- simple API for creating custom source
Installation
require("plug").add({
{
"wsdjeg/picker.nvim",
config = function()
require("picker").setup({
filter = {
ignorecase = false, -- ignorecase (boolean): defaults to false
},
window = {
width = 0.8, -- set picker screen width, default is 0.8 * vim.o.columns
height = 0.8,
col = 0.1,
row = 0.1,
current_icon = ">",
current_icon_hl = "CursorLine",
enable_preview = false,
preview_timeout = 500,
show_score = false, -- display/hide match score at the end of each item.
},
highlight = {
matched = "Tag",
score = "Comment",
},
prompt = {
position = "bottom", -- set prompt position, bottom or top
icon = ">",
icon_hl = "Error",
insert_timeout = 100,
title = true, -- display/hide source name
},
mappings = {
close = "<Esc>",
next_item = "<Tab>",
previous_item = "<S-Tab>",
open_item = "<Enter>",
toggle_preview = "<C-p>",
},
})
end,
},
})
Usage
Picker Command
- fuzzy finder picker source.
run :Picker command without source name.
:Picker
- open picker source.
run :Picker command with a name of source.
:Picker <name>
- specific default input
with --input option, users also can specific default input text.
:Picker file --input=foo
or use <cword> for word under cursor.
:Picker help_tags --input=<cword>
Key bindings
In picker prompt window, the these mappings are defined by default.
| key binding |
description |
Tab |
next item |
S-Tab |
previous item |
Enter |
default action |
Esc |
close picker |
Builtin sources
| source |
description |
| buffers |
listed buffers |
| buftags |
ctags outline for current buffer |
| cmd_history |
results from :history : |
| colorscheme |
all colorschemes |
| files |
files in current dir |
| help_tags |
neovim help tags source |
| highlights |
highlight group source |
| jumps |
jump list |
| lines |
lines in current buffer |
| loclist |
location list source |
| lsp_document_symbols |
document symbols result from lsp client |
| lsp_references |
lsp references |
| lsp_workspace_symbols |
workspace symbols |
| marks |
marks list |
| picker_config |
picker config source |
| qflist |
quickfix source |
| registers |
registers context |
files
The default commands for listing files is {'rg', '--files'}. this can be changed via:
require("picker.sources.files").set({ cmd = { "rg", "--files" } })
| key binding |
description |
<Enter> |
open select file |
<C-v> |
open select file in vertical split |
<C-t> |
open select file in new tabpage |
cmd_history
filter results from :history cmd.
| key binding |
description |
<Enter> |
execute select command |
<C-d> |
delete select command history |
picker_config
filter and setup picker.nvim without changing configuration file.
| items |
description |
| prompt-top |
change the prompt position to top |
| prompt-bottom |
change the prompt position to bottom |
| show-score |
display matched score |
| hide-score |
hide matched score |
| ignrecase |
change filter ignrecase to true |
| noignrecase |
change filter ignrecase to false |
| key binding |
description |
<Enter> |
set selected picker config |
highlights
filter results from :highlight
| key binding |
description |
<Enter> |
yank selected highlight group name |
async_files
same as files source, but require job.nvim.
| key binding |
description |
<Enter> |
open select file |
colorscheme
filter colorschemes.
| key binding |
description |
<Enter> |
change to selected colorscheme |
buftags
filter ctags outline, require ctags command.
| key binding |
description |
<Enter> |
jump to select tag |
buffers
file results from nvim_list_bufs()
| key binding |
description |
<Enter> |
switch to select buffer |
lines
| key binding |
description |
<Enter> |
jump to selected line |
help_tags
| key binding |
description |
<Enter> |
jump selected help tag |
qflist
| key binding |
description |
<Enter> |
jump selected quickfix list item |
loclist
| key binding |
description |
<Enter> |
jump selected loclist item |
registers
| key binding |
description |
<Enter> |
paste selected context |
jumps
| key binding |
description |
<Enter> |
jump selected position |
marks
| key binding |
description |
<Enter> |
jump selected position |
lsp_document_symbols
| key binding |
description |
<Enter> |
jump selected symbol |
lsp_workspace_symbols
| key binding |
description |
<Enter> |
jump selected symbol |
lsp_references
| key binding |
description |
<Enter> |
jump selected reference |
Third party sources
Custom source
a source main module should be picker.sources.<name>,
that means you can create a custom source in lua/picker/sources/ directory in your plugin.
--- @class PickerSource
--- @field get function
--- @field default_action function
--- @field __results nil | table<string>
--- @field preview_win boolean
--- @field preview function
--- @field set function
--- @field actions? table
FAQ
- how to disable nvim-cmp in picker.nvim buffer?
require("cmp").setup({
enabled = function()
if vim.bo.filetype == "picker-prompt" then
return false
end
return true
end,
})
- how to use picker.nvim as
vim.ui.select?
vim.ui.select = function(items, opt, callback)
local source = {}
opt = opt or {}
if opt.prompt then
source.name = opt.prompt
else
source.name = "Select one of:"
end
source.get = function()
local entrys = {}
for idx, item in ipairs(items) do
local entry = {
value = item,
idx = idx, -- this also can be nil
}
if opt.format_item then
entry.str = opt.format_item(item)
else
entry.str = item
end
table.insert(entrys, entry)
end
return entrys
end
source.default_action = function(entry)
if callback then
callback(entry.value, entry.idx)
end
end
require("picker.windows").open(source, {
buf = vim.api.nvim_get_current_buf(),
})
end
Self-Promotion
Like this plugin? Star the repository on
GitHub.
Love this plugin? Follow me on
GitHub.
Feedback
If you encounter any bugs or have suggestions, please file an issue in the issue tracker
Credits