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

bug: Suggested configuration breaks `nvim -c :Man!`

Open pinbraerts opened this issue 6 months ago • 0 comments

Did you check the docs and existing issues?

  • [X] I have read the docs
  • [X] I have searched the existing issues

Neovim version (nvim -v)

NVIM v0.11.0-dev-662+gc0a8abf18 Build type: Release LuaJIT 2.1.0-beta3 Run "nvim -V1 -v" for more info

Operating system/version

Debian 6.1.99-1

Describe the bug

The suggested snippets from README.md for saving/loading the configuration only if nvim was started with no args do not work when using nvim as man pager. I couldn't come up with a better condition for restoring the session.

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

  1. nvim -u repro.lua
  2. :q
  3. MANPAGER='nvim -u repro.lua -c :Man!' man echo

Expected Behavior

The session is not restored and man page is opened instead.

Directory structure

No response

Repro

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "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)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
   {
    "stevearc/resession.nvim",
    config = function()
      local resession = require("resession")
      resession.setup({})
      vim.api.nvim_create_autocmd("VimEnter", {
        callback = function()
          if vim.fn.argc(-1) == 0 then
            resession.load(vim.fn.getcwd(), { dir = ".session", silence_errors = true })
          end
        end,
        nested = true,
      })
      vim.api.nvim_create_autocmd("VimLeavePre", {
        callback = function()
          if vim.fn.argc(-1) == 0 then
            resession.save(vim.fn.getcwd(), { dir = ".session", notify = false })
          end
        end,
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

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

Did you check the bug with a clean config?

  • [X] I have confirmed that the bug reproduces with nvim -u repro.lua using the repro.lua file above.

pinbraerts avatar Aug 26 '24 16:08 pinbraerts