Isrothy / neominimap.nvim

Yet another minimap plugin for Neovim
MIT License
135 stars 3 forks source link

Errors on loading existing session #37

Closed oalders closed 1 month ago

oalders commented 1 month ago

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:

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.

oalders commented 1 month ago

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>
Isrothy commented 1 month ago

May I know your vim.o.sessionoptions?

oalders commented 1 month ago

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

Isrothy commented 1 month ago

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

oalders commented 1 month ago

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!

Isrothy commented 1 month ago

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.

oalders commented 1 month ago

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>