mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 03:08:13 +00:00
fix(dashboard): added optional filter for recent files
This commit is contained in:
parent
920a9d28f1
commit
32cd34383c
1 changed files with 11 additions and 9 deletions
|
@ -841,7 +841,7 @@ end
|
|||
|
||||
--- Get the most recent files, optionally filtered by the
|
||||
--- current working directory or a custom directory.
|
||||
---@param opts? {limit?:number, cwd?:string|boolean}
|
||||
---@param opts? {limit?:number, cwd?:string|boolean, filter?:fun(file:string):boolean?}
|
||||
---@return snacks.dashboard.Gen
|
||||
function M.sections.recent_files(opts)
|
||||
return function()
|
||||
|
@ -850,6 +850,7 @@ function M.sections.recent_files(opts)
|
|||
local root = opts.cwd and vim.fs.normalize(opts.cwd == true and vim.fn.getcwd() or opts.cwd) or ""
|
||||
local ret = {} ---@type snacks.dashboard.Section
|
||||
for file in M.oldfiles({ filter = { [root] = true } }) do
|
||||
if not opts.filter or opts.filter(file) then
|
||||
ret[#ret + 1] = {
|
||||
file = file,
|
||||
icon = "file",
|
||||
|
@ -860,6 +861,7 @@ function M.sections.recent_files(opts)
|
|||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue