diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index eae817c..1610d09 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -642,6 +642,7 @@ endfunction function! nerdtree#ui_glue#setupCommands() abort command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('') command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('') + command! -n=? -complete=dir -bar NERDTreeExplore :call g:NERDTreeCreator.CreateExploreTree('') command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close() command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('') command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 4dd7a31..7e1940b 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -38,6 +38,29 @@ function! s:Creator.BufNamePrefix() return 'NERD_tree_' endfunction +" FUNCTION: s:Creator.CreateExploreTree(dir) {{{1 +function! s:Creator.CreateExploreTree(dir) + try + let path = g:NERDTreePath.New(a:dir) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo('Invalid directory name:' . a:dir) + return + endtry + + let creator = s:Creator.New() + if getbufinfo('%')[0].changed && !&hidden && !&autowriteall + let l:splitLocation = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'top' ? 'topleft ' : 'botright ' + let l:splitDirection = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'right' ? 'vertical' : '' + silent! execute l:splitLocation . l:splitDirection . ' new' + else + silent! execute 'enew' + endif + + call creator.createWindowTree(a:dir) + "we want windowTree buffer to disappear after moving to any other buffer + setlocal bufhidden=wipe +endfunction + " FUNCTION: s:Creator.CreateTabTree(a:name) {{{1 function! s:Creator.CreateTabTree(name) let creator = s:Creator.New()