persisted.nvim icon indicating copy to clipboard operation
persisted.nvim copied to clipboard

[Bug]: no-neck-pain.nvim `disable` doesn't work in `SavePre` hook

Open okkdev opened this issue 1 month ago • 8 comments

Your minimal.lua 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 = {
      autoload = true,
    },
  },
  {
    "shortcuts/no-neck-pain.nvim",
    opts = {
      buffers = {
        scratchPad = {
          enabled = true,
          location = "/tmp/",
        },
        bo = {
          filetype = "md",
        },
      },
    },
  },
  -- Put any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

local persisted_hooks = vim.api.nvim_create_augroup("PersistedHooks", {})

vim.api.nvim_create_autocmd({ "User" }, {
  pattern = "PersistedSavePre",
  group = persisted_hooks,
  callback = function()
    require("no-neck-pain").disable()
  end,
})

Error messages

No response

Describe the bug

What I expect

After :quitting a file while using :NoNeckPain to center the code, I expect to get back into the file at the same position where I left off when loading the Session.

What happens instead

Persisted.nvim opens the side buffer of NoNeckPain instead of my file. Even though I disable NoNeckPain using the PersistedSavePre hook.

Reproduce the bug

Steps to reproduce:

  1. nvim
  2. :e some-file.txt
  3. :NoNeckPain
  4. :q
  5. nvim

Final checks

  • [X] I have made sure this issue exists in the latest version of the plugin
  • [X] I have tested with the minimal.lua config file above and still get the issue
  • [X] I have used SessionSave to save the session before restarting Neovim and using SessionLoad
  • [X] I have made sure this is not a duplicate issue

okkdev avatar May 15 '24 15:05 okkdev