This commit is contained in:
rzvxa 2023-10-09 04:50:43 +03:30
commit 0c9517d8ef
4 changed files with 21 additions and 9 deletions

View File

@ -178,7 +178,7 @@ autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_
```vim ```vim
" Open the existing NERDTree on each new tab. " Open the existing NERDTree on each new tab.
autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif autocmd BufWinEnter * if &buftype != 'quickfix' && getcmdwintype() == '' | silent NERDTreeMirror | endif
``` ```
or change your NERDTree-launching shortcut key like so: or change your NERDTree-launching shortcut key like so:
```vim ```vim

View File

@ -1130,7 +1130,7 @@ setting is used.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*NERDTreeWinPos* *NERDTreeWinPos*
Values: "left" or "right" Values: "left", "right", "top" or "bottom"
Default: "left". Default: "left".
This setting is used to determine where NERDTree window is placed on the This setting is used to determine where NERDTree window is placed on the
@ -1140,6 +1140,13 @@ This setting makes it possible to use two different explorer plugins
simultaneously. For example, you could have the taglist plugin on the left of simultaneously. For example, you could have the taglist plugin on the left of
the window and the NERDTree on the right. the window and the NERDTree on the right.
When setting this variable to "top" or "bottom" make sure to also change the
|NERDTreeWinSize| to a more reasonable size.
For example:
>
let g:NERDTreeWinSize = 15
<
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*NERDTreeWinSize* *NERDTreeWinSize*
Values: a positive integer. Values: a positive integer.

View File

@ -182,16 +182,17 @@ endfunction
" Initialize the NERDTree window. Open the window, size it properly, set all " Initialize the NERDTree window. Open the window, size it properly, set all
" local options, etc. " local options, etc.
function! s:Creator._createTreeWin() function! s:Creator._createTreeWin()
let l:splitLocation = g:NERDTreeWinPos ==# 'left' ? 'topleft ' : 'botright ' let l:splitLocation = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'top' ? 'topleft ' : 'botright '
let l:splitDirection = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'right' ? 'vertical' : ''
let l:splitSize = g:NERDTreeWinSize let l:splitSize = g:NERDTreeWinSize
if !g:NERDTree.ExistsForTab() if !g:NERDTree.ExistsForTab()
let t:NERDTreeBufName = self._nextBufferName() let t:NERDTreeBufName = self._nextBufferName()
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' new' silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' new'
silent! execute 'edit ' . t:NERDTreeBufName silent! execute 'edit ' . t:NERDTreeBufName
silent! execute 'vertical resize '. l:splitSize silent! execute l:splitDirection . ' resize '. l:splitSize
else else
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' split' silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' split'
silent! execute 'buffer ' . t:NERDTreeBufName silent! execute 'buffer ' . t:NERDTreeBufName
endif endif

View File

@ -422,6 +422,7 @@ function! s:TreeDirNode._initChildren(silent)
endif endif
let invalidFilesFound = 0 let invalidFilesFound = 0
let invalidFiles = []
for i in files for i in files
try try
let path = g:NERDTreePath.New(i) let path = g:NERDTreePath.New(i)
@ -429,6 +430,7 @@ function! s:TreeDirNode._initChildren(silent)
call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {}) call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {})
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
let invalidFilesFound += 1 let invalidFilesFound += 1
let invalidFiles += [i]
endtry endtry
endfor endfor
@ -438,7 +440,7 @@ function! s:TreeDirNode._initChildren(silent)
call nerdtree#echo('') call nerdtree#echo('')
if invalidFilesFound if invalidFilesFound
call nerdtree#echoWarning(invalidFilesFound . ' file(s) could not be loaded into the NERD tree') call nerdtree#echoWarning(invalidFilesFound . ' Invalid file(s): ' . join(invalidFiles, ', '))
endif endif
return self.getChildCount() return self.getChildCount()
endfunction endfunction
@ -580,6 +582,7 @@ function! s:TreeDirNode.refresh(...)
let files = self._glob('*', 1) + self._glob('.*', 0) let files = self._glob('*', 1) + self._glob('.*', 0)
let newChildNodes = [] let newChildNodes = []
let invalidFilesFound = 0 let invalidFilesFound = 0
let invalidFiles = []
for i in files for i in files
try try
"create a new path and see if it exists in this nodes children "create a new path and see if it exists in this nodes children
@ -596,7 +599,8 @@ function! s:TreeDirNode.refresh(...)
call add(newChildNodes, newNode) call add(newChildNodes, newNode)
endif endif
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
let invalidFilesFound = 1 let invalidFilesFound += 1
let invalidFiles += [i]
endtry endtry
endfor endfor
@ -605,7 +609,7 @@ function! s:TreeDirNode.refresh(...)
call self.sortChildren() call self.sortChildren()
if invalidFilesFound if invalidFilesFound
call nerdtree#echoWarning('some files could not be loaded into the NERD tree') call nerdtree#echoWarning(invalidFilesFound . ' Invalid file(s): ' . join(invalidFiles, ', '))
endif endif
let self.lazyRefresh = 0 let self.lazyRefresh = 0
" if this node is not empty and NERDTreeLazyDirRefresh is enable flag the node for lazyRefresh " if this node is not empty and NERDTreeLazyDirRefresh is enable flag the node for lazyRefresh