folke / persistence.nvim

💾 Simple session management for Neovim
Apache License 2.0
591 stars 26 forks source link

bug: E5108: Error executing lua: persistence/init.lua:39: Vim(autocmd):E216: No such group or event: Persistence #17

Closed surmish closed 1 year ago

surmish commented 1 year ago

Did you check docs and existing issues?

Neovim version (nvim -v)

https://github.com/neovim/neovim/commit/99cf111289bfcd14981255e805da43bac5139141

Operating system/version

linux

Describe the bug

I'm using latest LazyVim, lazy.nvim and persistence.nvim

I see the following on qd (Delete current session)

E5108: Error executing lua: ...hare/nvim/lazy/persistence.nvim/lua/persistence/init.lua:39: Vim(autocmd):E216: No such group or event: Persistence
stack traceback:
    [C]: in function 'cmd'
    ...hare/nvim/lazy/persistence.nvim/lua/persistence/init.lua:39: in function 'stop'
    ...1home57/urmish/.config/nvim/lua/lazyvim/plugins/util.lua:21: in function <...1home57/urmish/.config/nvim/lua/lazyvim/plugins/util.lua:21>
E5108: Error executing lua: ...hare/nvim/lazy/persistence.nvim/lua/persistence/init.lua:39: Vim(autocmd):E216: No such group or event: Persistence
stack traceback:
  -- session management
  {
    "folke/persistence.nvim",
    event = "BufReadPre",
    config = { options = { "buffers", "curdir", "tabpages", "winsize", "help" } },
    -- stylua: ignore
    keys = {
      { "<leader>qs", function() require("persistence").load() end, desc = "Restore Session" },
      { "<leader>ql", function() require("persistence").load({ last = true }) end, desc = "Restore Last Session" },
      { "<leader>qd", function() require("persistence").stop() end, desc = "Delete Current Session" },
    },
  },

Steps To Reproduce

<leader>qd

Expected Behavior

no error

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
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", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/persistence.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

  -- session management
  {
    "folke/persistence.nvim",
    event = "BufReadPre",
    config = { options = { "buffers", "curdir", "tabpages", "winsize", "help" } },
    -- stylua: ignore
    keys = {
      { "<leader>qs", function() require("persistence").load() end, desc = "Restore Session" },
      { "<leader>ql", function() require("persistence").load({ last = true }) end, desc = "Restore Last Session" },
      { "<leader>qd", function() require("persistence").stop() end, desc = "Delete Current Session" },
    },
  },

  -- library used by other plugins
  "nvim-lua/plenary.nvim",
}
folke commented 1 year ago

I just pushed a fix for this. It only happened when you stop persistence more than once.