I trying to access the vim.v.oldfiles
in my config.
I created a file nvim/lua/user/restore-on-reopen.lua
local project_root = require("project_nvim.project").get_project_root()
local oldfiles = vim.v.oldfiles
local target = nil
for _, filepath in pairs(oldfiles) do
if vim.startswith(filepath, project_root) then
target = filepath
break
end
end
vim.notify(vim.inspect(target))
-- Edit the file
-- TODO
Basically it supposed to reopen the last file from oldfiles
if it starts with the current project directory.
But when I open vim the vim.v.oldfiles
are empty. I tried moving it to nvim/after/plugins
but no oldfiles are shown.