olimorris / persisted.nvim

💾 Simple session management for Neovim with git branching, autoloading and Telescope support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: SessionSave / SessionLoad not working

rodolfoksveiga opened this issue · 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

  1. Use minimal.lua with my configuration data
  2. Start a clean NVim instance using minimal.lua
  3. Open a file in NVim
  4. Run SessionSave
  5. Quit NVim
  6. Open NVim again with minimal.lua
  7. 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 using SessionLoad
  • I have made sure this is not a duplicate issue
commented

Can you supply the minimal.lua file as per the bug report template? Impossible to try and recreate your issue without it

commented

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..?

commented

What if you remove the keys table?

commented

@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).

commented

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.