nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NvimTree does not open the file when it is open standalone

wookayin opened this issue · comments

When nvim-tree is working when "hijacking" directory buffers, it cannot open the file.

Reproduce:

  1. vim . (or after entering vim, e ., vs ., etc.)
  2. At this point, NvimTree will open in place of netrw (because it hijacks netrw upon FileExplorer)
  3. Press <CR> to open any file
  4. Nothing happens

It should work as Nerdtree and netrw would do.

Expected behavior:

  1. Open the file
  2. The current window (directory explorer) will be replaced by the file

so, what one could do to fix it?

for example, I've "hacked" it around by update_to_buf_dir=false (semi-sizes situation by itself) and au VimEnter * :bwipeout (because I hate that it keeps useless buffer after openinig the file) :D
But proper fix would be to bisect the code and revert the change when it become broken.
Or to fix it another way and create a PR.

well, and yes, I've disabled the picker.

@msva That would be a great workaround, at least the default netrw or nerdtree would work well.

Ideally we would keep NvimTree handle the directory buffer, but this seems to require quite lines of changes.

@i1skn I tried adding to L349 target_winid = api.nvim_get_current_win() to force nvim-tree to open the file in the "current" window (the same one as the directory buffer), but the nvim-tree window will still appear in the left (with some blinking UI glitches), which should be fixed by improving other relevant procedures.

@kyazdani42 Any updates?

#815 works to fix the bug itself, but it still doesn't work same as the netrw explorer when opening a directory buffer (e.g., only one nvim-tree buffer can present). I will open another issue about this. Thank you for the fix.