Closed eyev0 closed 1 year ago
This is useful, because otherwise I have to delete files manually. As a workaround we can create such function:
function()
local M = require("persistence")
local sfile = M.current()
if sfile and vim.loop.fs_stat(sfile) ~= 0 then
M.stop()
vim.fn.system("rm " .. vim.fn.fnameescape(sfile))
end
end
and bind it. E.g. in lazyvim I have:
{
"folke/persistence.nvim",
event = { "BufReadPre", "BufWipeout" }, -- Exclude closed files too
opts = {},
-- stylua: ignore
keys = {
{ "<leader>qs", function() require("persistence").load() end, desc = "Restore Session" },
{ "<leader>qS", function() require("persistence").select() end,desc = "Select Session" },
{ "<leader>ql", function() require("persistence").load({ last = true }) end, desc = "Restore Last Session" },
{ "<leader>qd", function() require("persistence").stop() end, desc = "Don't Save Current Session" },
{
"<leader>qD",
function()
local M = require("persistence")
local sfile = M.current()
if sfile and vim.loop.fs_stat(sfile) ~= 0 then
M.stop()
vim.fn.system("rm " .. vim.fn.fnameescape(sfile))
end
end,
desc = "Delete Current Session"
},
},
}
Any particular reason why this was closed? Seems like a nice extension.