[Bug]: SessionSave / SessionLoad not working
rodolfoksveiga opened this issue · 8 comments
Persisted.nvim config
local root = "/tmp/persisted"
-- Set stdpaths to use root dir
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- Bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
vim.opt.sessionoptions = "buffers,curdir,folds,globals,tabpages,winpos,winsize" -- Session options to store in the session
-- Install plugins
local plugins = {
{
"olimorris/persisted.nvim",
opts = {
"olimorris/persisted.nvim",
event = "VimEnter",
keys = {
{ "<leader>ss", "<cmd>SessionSave<cr>", desc = "Save" },
{ "<leader>sl", "<cmd>SessionLoad<cr>", desc = "Load" },
},
config = true,
opts = {
save_dir = vim.fn.expand(vim.fn.stdpath("data") .. "/sessions/"),
command = "",
silent = false,
use_git_branch = true,
branch_separator = "_",
autosave = false,
autoload = false,
}
},
-- Put any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
Error messages
There are no error messages.
Bug description
SessionSave
and SessionLoad
commands are currently not working.
I followed your instructions with minimal.lua
and tried to open some files, run SessionSave
, quit NVim and run SessionLoad
, but nothing is happens. I don't get errors or any message that could help me further.
Could you help me with that.
How to reproduce the bug
- Use
minimal.lua
with my configuration data - Start a clean NVim instance using
minimal.lua
- Open a file in NVim
- Run
SessionSave
- Quit NVim
- Open NVim again with
minimal.lua
- Run
SessionLoad
Final checks
- I have made sure this issue exists in the latest version of the plugin
- I have tested with the
minimal.lua
config file above and still get the issue - I have used
SessionSave
to save the session before restarting Neovim and usingSessionLoad
- I have made sure this is not a duplicate issue
Can you supply the minimal.lua
file as per the bug report template? Impossible to try and recreate your issue without it
Closing for now
Copying the returned value from my persisted.lua
configuration would do it. But I already updated the issue.
Can you reopen it..?
What if you remove the keys
table?
@rodolfoksveiga any update on this?
Sorry for taking so long... I removed the keys
table but SessionSave
and SessionLoad
still don't work, even if I call these commands from cmd
(without key bindings).
Right, I amended your minimal.lua
config to work:
local root = "/tmp/persisted"
-- Set stdpaths to use root dir
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- Bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
vim.opt.sessionoptions = "buffers,curdir,folds,globals,tabpages,winpos,winsize" -- Session options to store in the session
-- Install plugins
local plugins = {
{
"olimorris/persisted.nvim",
opts = {
save_dir = "/tmp/persisted/sessions/",
silent = false,
use_git_branch = true,
branch_separator = "_",
autosave = false,
autoload = false,
},
},
-- Put any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
and isolated the issue. Thanks for spotting! That was a real edge case!
I have no idea how, but my configuration remains the same and the problem is solved. You probably have tackled it in a bug fix or so. Thanks anyway for your help. And congrats for developing such a useful plugin.