mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-22 04:35:39 +08:00
feat: add NERDTreeExplore command. (#1389)
* create a explorer command that opens a window tree at specified directory * update CHANGELOG.md * Update CHANGELOG.md * revert CHANGELOG.md * CreateExplorerTree matches :Explore command * prevent empty split when calling NERDTreeExplorer with invalid arg from modified buffer * NERDTreeExplore/CreateExploreTree checks for hidden and autowriteall settings
This commit is contained in:
parent
a954661824
commit
fefea5d382
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user