Skip to content

Commit 985ac9e

Browse files
committed
feat(oldfiles): customize shada file
Supply custom shada file to read using `:rshada!` (opts.shada), enables oldfiles from the cli.
1 parent ffa44ee commit 985ac9e

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

lua/fzf-lua/defaults.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,8 @@ M.defaults.args = {
10101010

10111011
---File history (output of `:oldfiles`).
10121012
---@class fzf-lua.config.Oldfiles: fzf-lua.config.Base
1013+
---Optional shada file to read, see `:help shada`
1014+
---@field shada? string
10131015
---Only include files that still exist on disk.
10141016
---@field stat_file? boolean
10151017
---Include files opened during the current session.

lua/fzf-lua/providers/oldfiles.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ M.oldfiles = function(opts, globals)
7171
local curr_file = vim.api.nvim_buf_get_name(curr_buf)
7272
local sess_map = {} -- dedup files from current buffers
7373

74+
-- read the optional shada file
75+
if opts.shada then
76+
local file = vim.fs.normalize(opts.shada)
77+
if vim.uv.fs_stat(file) then
78+
vim.cmd("rshada! " .. file)
79+
else
80+
utils.warn("shada file '%s' does not exist, ignoring.", opts.shada)
81+
end
82+
end
83+
7484
local function add_entry(x, co, force)
7585
x = make_entry.file(x,
7686
force and vim.tbl_deep_extend("force", {}, opts, { cwd_only = false }) or opts)

0 commit comments

Comments
 (0)