A lightweight Neovim plugin to manage and display your Most Recently Used (MRU) files.
mru.nvim keeps track of the files you've recently opened in Neovim and
provides quick access to them via quickfix, picker.nvim, or telescope.nvim extension.
mru.nvim does not aim to replace v:oldfiles directly.
Instead, it maintains its own MRU tracking to address several practical limitations:
v:oldfiles may contain inconsistent or duplicated paths on Windows.lastenter, lastread, lastmod, or frecency.Use your preferred Neovim plugin manager to install mru.nvim.
Using nvim-plug:
require('plug').add({
{ 'wsdjeg/mru.nvim' }
})
Then use :PlugInstall mru.nvim to install this plugin.
Using LuaRocks:
luarocks install mru.nvim
The following is the default option of mru.nvim.
require('mru').setup({
-- enable or disable cache (default: true)
enable_cache = true,
-- cache file path (default: stdpath('data') .. '/nvim-mru.json')
mru_cache_file = vim.fn.stdpath('data') .. '/nvim-mru.json',
-- backup file path (default: stdpath('data') .. '/nvim-mru-backup.json')
mru_backup_file = vim.fn.stdpath('data') .. '/nvim-mru-backup.json',
-- table of regex to ignore paths (default: {})
ignore_path_regexs = { '/.git/' },
-- enable logger.nvim (default: false, requires wsdjeg/logger.nvim)
enable_logger = false,
-- sort strategy: `lastenter`, `lastread`, `lastmod`, or `frecency`
-- default: `lastenter`
sort_by = 'lastenter',
})
| Command | Description |
|---|---|
:Mru |
List MRU files in the quickfix window |
:Mru remove {re} |
Remove files matching regex from the MRU list |
| Function | Description |
|---|---|
require('mru').setup(opt) |
Initialize the plugin with options |
require('mru').get() |
Returns a sorted list of MRU file paths |
require('mru').clear() |
Backup current list to backup file, then clear |
require('mru').recover() |
Restore MRU list from backup file |
require('mru').remove(regex) |
Remove files matching regex from MRU list |
require('mru').calculate_frecentcy(f) |
Calculate frecency score for a file |
Run :Mru to list all MRU files in the quickfix window:
:Mru
Remove files matching a regex pattern:
:Mru remove \.tmp$
Or via Lua API:
require('mru').remove('\\.tmp$')
mru.nvim provides a source for picker.nvim,
which can be opened via :Picker mru.
Key bindings for picker mru extension:
| Key Binding | Description |
|---|---|
<Enter> |
Open file in the current window |
<C-s> |
Open file in a horizontal split window |
<C-v> |
Open file in a vertical split window |
<C-t> |
Open file in a new tab |
vim.api.nvim_set_keymap('n', '<leader>m', ':Picker mru<CR>', { noremap = true, silent = true })
mru.nvim also provides a telescope.nvim extension:
vim.api.nvim_set_keymap('n', '<leader>m', ':Telescope mru<CR>', { noremap = true, silent = true })
Now, pressing <leader>m (e.g., \m by default) will open the MRU list.
Like this plugin? Star the repository on GitHub.
Love this plugin? Follow me on GitHub.
This project is licensed under the GPL-3.0 License.