nvim-neo-tree / neo-tree.nvim

Neovim plugin to manage the file system and other tree like structures.
MIT License
3.61k stars 210 forks source link

Conflict between alpha.nvim and preview feature #490

Open cseickel opened 2 years ago

cseickel commented 2 years ago

Greatest feature! When there's no open buffer (such as starting with the alpha-nvim greeting), disabling preview causes some errors: Other than that, it works great.

E5108: Error executing lua: ...rt/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:150: Vim(append):Error executing lua callback: ..
.are/nvim/site/pack/packer/start/alpha-nvim/lua/alpha.lua:550: Cursor position outside buffer
stack traceback:
        [C]: in function 'nvim_win_set_cursor'
        ...are/nvim/site/pack/packer/start/alpha-nvim/lua/alpha.lua:550: in function 'draw'
        ...are/nvim/site/pack/packer/start/alpha-nvim/lua/alpha.lua:566: in function 'redraw'
        ...are/nvim/site/pack/packer/start/alpha-nvim/lua/alpha.lua:473: in function <...are/nvim/site/pack/packer/start/alpha-nvim/lua/a
lpha.lua:473>
        [C]: in function 'nvim_win_set_buf'
        ...rt/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:150: in function 'setBuffer'
        ...rt/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:73: in function 'revert'
        ...t/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:400: in function 'func'
        .../packer/start/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:695: in function <.../packer/start/neo-tree.nvim/lua/neo-tree/ui/rend
erer.lua:693>
stack traceback:
        [C]: in function 'nvim_win_set_buf'
        ...rt/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:150: in function 'setBuffer'
        ...rt/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:73: in function 'revert'
        ...t/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:400: in function 'func'
        .../packer/start/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:695: in function <.../packer/start/neo-tree.nvim/lua/neo-tree/ui/rend
erer.lua:693>

Originally posted by @barreiroleo in https://github.com/nvim-neo-tree/neo-tree.nvim/issues/482#issuecomment-1217084511

cseickel commented 2 years ago

@barreiroleo @mrbjarksen I don't have alpha.nvim, but I'm pretty sure the fix I just pushed will prevent this error. Can you give it a try?

barreiroleo commented 2 years ago

Yeah, works well :+1:

barreiroleo commented 2 years ago

After update and reenable the preview command, the issue come up again.

E5108: Error executing lua: ...rt/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:153: Vim(append):Error executing lua callback: ...are/nvim/site/pack/packer/start/alpha-nvim/lua/alpha.lua:550: Cursor position outside buffer
stack traceback:
        [C]: in function 'nvim_win_set_cursor'
        ...are/nvim/site/pack/packer/start/alpha-nvim/lua/alpha.lua:550: in function 'draw'
        ...are/nvim/site/pack/packer/start/alpha-nvim/lua/alpha.lua:566: in function 'redraw'
        ...are/nvim/site/pack/packer/start/alpha-nvim/lua/alpha.lua:473: in function <...are/nvim/site/pack/packer/start/alpha-nvim/lua/alpha.lua:473>
        [C]: in function 'nvim_win_set_buf'
        ...rt/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:153: in function 'setBuffer'
        ...rt/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:78: in function 'revert'
        ...t/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:379: in function 'func'
        .../packer/start/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:696: in function <.../packer/start/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:694>
stack traceback:
        [C]: in function 'nvim_win_set_buf'
        ...rt/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:153: in function 'setBuffer'
        ...rt/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:78: in function 'revert'
        ...t/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:379: in function 'func'
        .../packer/start/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:696: in function <.../packer/start/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:694>
cseickel commented 2 years ago

Could it be that the issue is just inconsistent, and that's why it seemed to be fixed? You just got lucky on the last try?

cseickel commented 2 years ago

I'm looking at the code for alpha.nvim, and I think this is really a bug in that project that was just revealed by this project. This is probably the only situation where the alpha.nvim is navigated away from and then back to again. I see three possible solutions:

  1. Set redraw_on_resize = false in your alpha.nvim config, this will disable the problematic code block.
  2. Open an issue on the alpha.nvim project so that the set_cursor call can be changed to a pcall or otherwise checked for validity before being run.
  3. I can put a special handler in place to never revert the buffer when alpha.nvim would be the target.
barreiroleo commented 2 years ago

I have a 4th option: Don't use alpha anymore, haha It isn't a necessary plugin really. For someone else, it might be helpful if alpha.nvim resolves their bug. If it's not your responsibility, don't care about it.

cseickel commented 2 years ago

I have a 4th option: Don't use alpha anymore, haha It isn't a necessary plugin really.

In that case, I'll just leave the issue open for others to find. If there is a lot of interest I might do option 2 or 3.