mikavilpas / yazi.nvim

A Neovim Plugin for the yazi terminal file manager
MIT License
243 stars 7 forks source link

Invalid window id error when press q to quit #36

Closed isvicy closed 2 months ago

isvicy commented 2 months ago

when press q to quit or press enter to open a file in yazi.nvim ui, invalid window id error pops up. here is the detail:

trace

    /home/ak2kay/.local/share/nvim/lazy/yazi.nvim/lua/yazi.lua:48: in function </home/ak2kay/.local/share/nvim/lazy/yazi.nvim/lua/yazi.lua:41> function: builtin#18 ...2kay/.local/share/nvim/lazy/yazi.nvim/lua/yazi/utils.lua:194: Invalid window id: 1372
stack traceback:
    [C]: in function 'nvim_win_close'
    ...2kay/.local/share/nvim/lazy/yazi.nvim/lua/yazi/utils.lua:194: in function 'on_yazi_exited'
    /home/ak2kay/.local/share/nvim/lazy/yazi.nvim/lua/yazi.lua:48: in function </home/ak2kay/.local/share/nvim/lazy/yazi.nvim/lua/yazi.lua:41>

versions:

❯ yazi --version
Yazi 0.2.4 (Homebrew 2024-04-17)
❯ nvim --version
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1710088188

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/linuxbrew/.linuxbrew/Cellar/neovim/0.9.5/share/nvim"

Run :checkhealth for more info

config:

{
    "mikavilpas/yazi.nvim",
    dependencies = {
      "nvim-lua/plenary.nvim",
    },
    event = "VeryLazy",
    keys = {
      {
        -- 👇 choose your own keymapping
        "<leader>fy",
        function()
          require("yazi").yazi()
        end,

        { desc = "Open the file manager" },
      },
    },
    opts = {
      open_for_directories = false,
    },
  }
mikavilpas commented 2 months ago

Can you see if you can reproduce the issue with these instructions:

I am unable to reproduce the issue.

isvicy commented 2 months ago

I can confirm that if i use the reproduction configuration you provided, this issue will not occur.

and the pr i made solve the issue for my case. in this case, i think the issue i met could be introduced by other plugin i used, mostly could be related to autocmds conflicts. i use https://github.com/LazyVim/LazyVim as my base config. i will try to find the root cause in my spare time.

you can make a decision if the pr can be merged just as a precaution.

isvicy commented 2 months ago

use this plugin alongside yazi.nvim will reproduce the issue i met. reproduce config:

-- 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)
vim.g.mapleader = " "

-- install plugins
local plugins = {
    "folke/tokyonight.nvim",
    {
        "mikavilpas/yazi.nvim",
        dependencies = {
            "nvim-lua/plenary.nvim",
        },
        event = "VeryLazy",
        keys = {
            {
                -- 👇 choose your own keymapping
                "<leader>fy",
                function()
                    require("yazi").yazi()
                end,

                { desc = "Open the file manager" },
            },
        },

        opts = {
            open_for_directories = false,
        },
    },
    { "zbirenbaum/nvterm", opts = {} },
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

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