Isrothy/neominimap.nvim

Errors on loading existing session

oalders opened this issue · 7 comments

Describe the bug

Error executing vim.schedule lua callback: .../share/nvim/lazy/neominimap.nvim/lua/neominimap/util.lua:12: Invalid window id: 1002
stack traceback:
[C]: in function 'f'
.../share/nvim/lazy/neominimap.nvim/lua/neominimap/util.lua:12: in function <.../share/nvim/lazy/neominimap.nvim/lua/neominimap/util.lua:9>
...hare/nvim/lazy/neominimap.nvim/lua/neominimap/window.lua:280: in function 'refresh_minimap_window'
...local/share/nvim/lazy/neominimap.nvim/lua/neominimap.lua:147: in function <...local/share/nvim/lazy/neominimap.nvim/lua/neominimap.lua:141>

To Reproduce
I'm using olimorris/persisted.nvim to manage sessions. The maps work fine in a new session. If I exit neovim and then re-enter the session I just left, no map appears and the error above is displayed.

Expected behavior
Ideally the plugin would pick up where it left off. In this case, there's just no more map.

Please complete the following information:

  • OS: Ubuntu 20.04.6 LTS
  • Neovim Version: v0.11.0-dev-364+g73ae7d44a

Additional context
My lazy.nvim config:

    {
        'Isrothy/neominimap.nvim',
        enabled = true,
        lazy = false,                  -- WARN: NO NEED to Lazy load
        init = function()
            vim.opt.wrap = false       -- Recommended
            vim.opt.sidescrolloff = 36 -- It's recommended to set a large value
            vim.g.neominimap = {     ■ Fields cannot be injected into the reference of `vim.var_accessor` for `neominimap`. To do so, use `---@class` for `vim.g`.
                auto_enable = true,
            }
        end,
    },

I can NeominimpaClose and then NeominimapOpen to revive the map.

I see that this has been fixed in the newest version. I upgraded this morning and the map is preserved. I am, however, now seeing:

Error executing vim.schedule lua callback: ...hare/nvim/lazy/neominimap.nvim/lua/neominimap/buffer.lua:99: Invalid buffer id: 1
stack traceback:
        [C]: in function 'nvim_buf_get_lines'
        ...hare/nvim/lazy/neominimap.nvim/lua/neominimap/buffer.lua:99: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

May I know your vim.o.sessionoptions?

blank,buffers,curdir,folds,help,tabpages,winsize,terminal

Could you please provide the minimal full Neovim configuration? I am unable to reproduce this bug.

It turns out I cannot replicate this with a minimal configuration. Apologies for not trying this in advance. I'll close this issue and re-open if I can figure out which plugin is causing the interaction. Thanks for your help!

Although I cannot reproduce this bug, I came up with a hack based on your description: turn the minimap off and on again on the PersistedLoadPost event.

vim.api.nvim_create_autocmd({ "User" }, {
	group = vim.api.nvim_create_augroup("persisted", { clear = true }),
	pattern = "PersistedLoadPost",
	callback = function()
		vim.cmd("Neominimap off")
		vim.cmd("Neominimap on")
	end,
})

I hope this works.

Thanks for looking into this. It looks like with the latest version of the plugin and your hack I now get:

Error executing vim.schedule lua callback: .../share/nvim/lazy/neominimap.nvim/lua/neominimap/util.lua:12: Invalid window id: 1003
stack traceback:
[C]: in function 'f'
.../share/nvim/lazy/neominimap.nvim/lua/neominimap/util.lua:12: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>