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

Add split explorer to NERDTree #1389

Merged
merged 7 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions autoload/nerdtree/ui_glue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ endfunction
function! nerdtree#ui_glue#setupCommands() abort
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('<args>')
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('<args>')
command! -n=? -complete=dir -bar NERDTreeExplore :call g:NERDTreeCreator.CreateExploreTree('<args>')
command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close()
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('<args>')
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
Expand Down
23 changes: 23 additions & 0 deletions lib/nerdtree/creator.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
rzvxa marked this conversation as resolved.
Show resolved Hide resolved
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()
Expand Down