MRU Buffer Picker is a small, dependency-free Neovim plugin for switching to a recent buffer with one or two keystrokes. It opens a centered floating window with the oldest visible buffer at the top and the newest at the bottom. The newest entries receive the highest-priority hints.
With keys = "asdf" and seven visible buffers, hints are allocated in
newest-to-oldest priority order as:
a, s, d, fa, fs, fd, ff
Typing a, s, or d selects immediately. Typing f keeps the matching
buffers in their original rows, blanks the others, and shows the remaining
one-character suffixes. Backspace restores the full list.
- Neovim 0.8 or newer
- No runtime dependencies
Use any Neovim package manager. For example, with lazy.nvim:
{
"ckw/mru-buffer-picker.nvim",
opts = {
keys = "asdfghjkl;",
},
keys = {
{ "<leader>b", function() require("mru_buffer_picker").open() end },
},
}The plugin starts tracking on load, even if setup() is never called.
require("mru_buffer_picker").setup({
keys = "asdfghjkl;",
})keys defaults to "asdfghjkl;". It may be a string or an ordered list of
unique, one-character printable ASCII keys:
require("mru_buffer_picker").setup({
keys = { "a", "s", "d", "f" },
})At least two keys are required. Their configured order is preserved and determines hint priority; uppercase and lowercase keys are distinct.
Open the picker with either API:
:MruBufferPickerrequire("mru_buffer_picker").open()The current buffer is not shown. A complete hint switches the window from which the picker was opened to the selected buffer. The switch obeys normal Neovim modified-buffer rules and never forces an edit.
Esccancels.Backspaceat the filtered second level returns to the complete list.- Invalid printable keys, unhandled special/control keys, and mouse input cancel.
- Leaving the picker, losing editor focus, or resizing Neovim cancels.
- Calling
open()while a picker is already visible leaves that picker alone.
With A configured keys, the picker can represent at most A² buffers. It
also cannot exceed the available editor height. When either limit applies,
only the newest buffers that fit are displayed.
The picker tracks valid, listed normal and terminal buffers. Named and unnamed
buffers are eligible, as are modified buffers. Help, quickfix, prompt,
nofile, unlisted, deleted, and picker-internal buffers are excluded.
Buffers that already exist when tracking starts receive a deterministic alphabetical baseline order. After that, entering a buffer makes it the newest entry, and re-entering it moves it to the bottom of the picker.
The first unconsumed hint character uses MruBufferPickerHint, which defaults
to bold red on white. Override it after your colorscheme loads:
vim.api.nvim_set_hl(0, "MruBufferPickerHint", {
fg = "#ff5555",
bold = true,
})Run the policy, state, UI, lifecycle, and headless loading tests with:
make testThe test harness uses only Neovim itself.