neo-tree.nvim icon indicating copy to clipboard operation
neo-tree.nvim copied to clipboard

Conflict between alpha.nvim and preview feature

Open cseickel opened this issue 2 years ago • 7 comments

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 avatar Aug 16 '22 20:08 cseickel

@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?

cseickel avatar Aug 17 '22 01:08 cseickel

Yeah, works well :+1:

barreiroleo avatar Aug 17 '22 01:08 barreiroleo

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>

barreiroleo avatar Aug 22 '22 00:08 barreiroleo

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 avatar Aug 22 '22 12:08 cseickel

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.

cseickel avatar Aug 22 '22 12:08 cseickel

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.

barreiroleo avatar Aug 22 '22 16:08 barreiroleo

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.

cseickel avatar Aug 22 '22 16:08 cseickel