A small Neovim plugin for quick MRU navigation:
- MRU file history nav: shows previously edited files in MRU order, including across restarts
- MRU buffer nav: shows open buffers in MRU order for the current session
- Works with
vim.ui.select()out of the box - Uses Telescope automatically when installed, unless disabled
- Friendly lazy.nvim setup
:MruFileopens a picker for persisted MRU file history:MruBufferopens a picker for currently open buffers in MRU order- command-line aliases so
:mruFileand:mruBufferalso work - default keymaps for quick access
- persisted file history stored under Neovim's state directory
- Neovim
>= 0.9 - Optional: Telescope for a nicer picker UI
{
"mjacobs/mru-nav.nvim",
cmd = { "MruFile", "MruBuffer", "MruClearFiles" },
keys = {
{ "<leader>mf", function() require("mru_nav").mru_files() end, desc = "MRU file picker" },
{ "<leader>mb", function() require("mru_nav").mru_buffers() end, desc = "MRU buffer picker" },
},
opts = {
keymaps = {
files = "<leader>mf",
buffers = "<leader>mb",
},
},
config = function(_, opts)
require("mru_nav").setup(opts)
end,
}:MruFile— pick a file from persisted MRU history:MruBuffer— pick an open buffer from current-session MRU order:MruClearFiles— clear persisted file history
Because Neovim user commands should start with an uppercase letter, the plugin defines :MruFile and :MruBuffer as the real commands. It also adds command-line abbreviations so typing :mruFile and :mruBuffer still works.
<leader>mf— MRU files<leader>mb— MRU buffers
Set either value to false or "" to skip creating that keymap.
require("mru_nav").setup({
max_files = 200,
max_buffers = 100,
persist = true,
history_file = nil, -- defaults to stdpath("state") .. "/mru-nav.json"
use_telescope_if_available = true,
file_picker_title = "MRU Files",
buffer_picker_title = "MRU Buffers",
keymaps = {
files = "<leader>mf",
buffers = "<leader>mb",
},
})| Option | Default | Meaning |
|---|---|---|
max_files |
200 |
Max number of persisted files to keep |
max_buffers |
100 |
Max number of in-memory MRU buffers to keep |
persist |
true |
Whether file MRU history is saved across restarts |
history_file |
stdpath("state") .. "/mru-nav.json" |
Storage path for file history |
use_telescope_if_available |
true |
Prefer Telescope over vim.ui.select() when available |
file_picker_title |
"MRU Files" |
Prompt title for file picker |
buffer_picker_title |
"MRU Buffers" |
Prompt title for buffer picker |
keymaps.files |
"<leader>mf" |
Normal-mode keymap for files |
keymaps.buffers |
"<leader>mb" |
Normal-mode keymap for buffers |
Persisted file history is stored in JSON at:
vim.fs.joinpath(vim.fn.stdpath("state"), "mru-nav.json")The plugin writes updates atomically using a temp file + rename, and prunes missing files when opening the file picker or exiting Neovim.
- File history is cross-session
- Buffer history is session-local by design
- Special buffers such as help, quickfix, terminal, and other non-file buffers are excluded from file history
- Buffer picker includes listed buffers, even if they do not yet have a file on disk
- Open a few files in sequence
- Run
:MruFile - Confirm they appear newest-first
- Restart Neovim
- Run
:MruFileagain and confirm the order persisted - Run
:MruBufferand confirm open buffers are shown newest-first
mru-nav.nvim/
├── lua/mru_nav/init.lua
├── plugin/mru_nav.lua
├── tests/minimal_init.lua
├── tests/smoke.lua
└── README.md