olimorris / persisted.nvim

💾 Simple session management for Neovim with git branching, autoloading and Telescope support
MIT License
418 stars 24 forks source link

[Bug]: SessionSave / SessionLoad not working #61

Closed rodolfoksveiga closed 1 year ago

rodolfoksveiga commented 1 year ago

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

olimorris commented 1 year ago

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

olimorris commented 1 year ago

Closing for now

rodolfoksveiga commented 1 year ago

Copying the returned value from my persisted.lua configuration would do it. But I already updated the issue.

Can you reopen it..?

olimorris commented 1 year ago

What if you remove the keys table?

olimorris commented 1 year ago

@rodolfoksveiga any update on this?

rodolfoksveiga commented 1 year ago

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

olimorris commented 1 year ago

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!

rodolfoksveiga commented 1 year ago

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.