I'm using Neovim v0.4.4
Basically i configured nerdtree to open in a tab on the left side, using more or less the same configuration i used in other nerdtree installation.
Basically if i try to navigate to the file in the nerdtree pane using keyboard and i open it pressing enter the Nerdtree pane disappear, and i see the message: "Nerdtree: no trees to mirror"
But if i open the same file pressing "o" or "t" or double clicking on it, the tree stays open.
The configuration i'm using is:
autocmd vimenter * NERDTree | wincmd w
autocmd StdinReadPre * let s:std_in=1
autocmd BufWinEnter * NERDTreeMirror
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
autocmd FileType nerdtree let t:nerdtree_winnr = bufwinnr('%')
autocmd BufWinEnter * NERDTreeMirror
" Exit Vim if NERDTree is the only window left.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() |
\ quit | endif
" Open the existing NERDTree on each new tab.
autocmd VimEnter * NERDTree
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | wincmd p | ene | exe 'NERDTree' argv()[0] | endif
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let g:NERDTreeMapOpenInTab = 'o'
I saw that closed issue that could be related to my problem: https://github.com/preservim/nerdtree/issues/145 But unfortunately the link there is no longer active, so i can't try the solution proposed.
I'm using neovim on fedora 33
Btw i think that the no trees to mirror is not really related to my issue!
I can confirm this bug. Although I do not get the "no trees to mirror" message.
I'm experiencing the same error within NeoVim on macOS. No error messages though.
Try
let NERDTreeCustomOpenArgs = {'file': {'reuse': 'all', 'where': 'p', 'keepopen': 1}, 'dir': {}}
The important option is 'keepopen': 1. The other options are the default values.
See :help NERDTreeCustomOpenArgs
It seems this new behaviour was introduced yesterday but I didn't investigate the actual cause.
Try
let NERDTreeCustomOpenArgs = {'file': {'reuse': 'all', 'where': 'p', 'keepopen': 1}, 'dir': {}}The important option is 'keepopen': 1. The other options are the default values.
See
:help NERDTreeCustomOpenArgsIt seems this new behaviour was introduced yesterday but I didn't investigate the actual cause.
Can confirm this works. Thanks!
Yeah, i too can confirm it works!!
Thanks for the help!
One of the recent pull requests changed the default behavior of the <CR> key. I will fix it, and you can remove the let NERDTreeCustomOpenArgs = ... statement if you prefer. The fix will be out later today.
@dreamos82 The "no trees to mirror" error message you're seeing is caused by your autocommand statement:
autocmd BufWinEnter * NERDTreeMirror
It's an entirely expected message to appear, especially before you've opened any NERDTree, but to get rid of it, change that statement to this:
autocmd BufWinEnter * silent NERDTreeMirror
Thank you @PhilRunninger!
I can confirm that after last pull from git it works even without the .vimrc config line you suggested.
Most helpful comment
One of the recent pull requests changed the default behavior of the
<CR>key. I will fix it, and you can remove thelet NERDTreeCustomOpenArgs = ...statement if you prefer. The fix will be out later today.