Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When opening a file Nerdtree disappear (only if i open the file with enter) #1220

Closed
dreamos82 opened this issue Feb 10, 2021 · 9 comments · Fixed by #1221
Closed

When opening a file Nerdtree disappear (only if i open the file with enter) #1220

dreamos82 opened this issue Feb 10, 2021 · 9 comments · Fixed by #1221
Labels

Comments

@dreamos82
Copy link

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: #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

@dreamos82 dreamos82 added the bug label Feb 10, 2021
@dreamos82
Copy link
Author

Btw i think that the no trees to mirror is not really related to my issue!

@dead10ck
Copy link

I can confirm this bug. Although I do not get the "no trees to mirror" message.

@rollschild
Copy link

I'm experiencing the same error within NeoVim on macOS. No error messages though.

@emi2k01
Copy link

emi2k01 commented Feb 10, 2021

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.

@rollschild
Copy link

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.

Can confirm this works. Thanks!

@dreamos82
Copy link
Author

Yeah, i too can confirm it works!!
Thanks for the help!

@PhilRunninger
Copy link
Member

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.

@PhilRunninger
Copy link
Member

@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

@dreamos82
Copy link
Author

Thank you @PhilRunninger!

I can confirm that after last pull from git it works even without the .vimrc config line you suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants