Merge pull request #180 from pendulm/master
For recusive open single directory child
This commit is contained in:
commit
e7b663fe94
@ -654,6 +654,10 @@ NERD tree. These options should be set in your vimrc.
|
|||||||
|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of
|
|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of
|
||||||
+ ~ chars when displaying directories.
|
+ ~ chars when displaying directories.
|
||||||
|
|
||||||
|
|'NERDTreeCasadeOpenSingleChildDir'|
|
||||||
|
Casade open while selected directory has only
|
||||||
|
one child that also is a directory.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2. Customisation details *NERDTreeOptionDetails*
|
3.2. Customisation details *NERDTreeOptionDetails*
|
||||||
|
|
||||||
@ -965,6 +969,20 @@ option: >
|
|||||||
let NERDTreeDirArrows=1
|
let NERDTreeDirArrows=1
|
||||||
<
|
<
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'NERDTreeCasadeOpenSingleChildDir'*
|
||||||
|
Values: 0 or 1
|
||||||
|
Default: 0.
|
||||||
|
|
||||||
|
This option tell NERDTree open the child directory if the selected opening
|
||||||
|
directory has only one child that is a directory, and do same to sub-directory
|
||||||
|
recursively. NERDTree will stop till it find a empty directory or this
|
||||||
|
directory has more than one child. This option may be useful for Java projects.
|
||||||
|
Use one of the follow lines to set this option: >
|
||||||
|
let NERDTreeCasadeOpenSingleChildDir=0
|
||||||
|
let NERDTreeCasadeOpenSingleChildDir=1
|
||||||
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
4. The NERD tree API *NERDTreeAPI*
|
4. The NERD tree API *NERDTreeAPI*
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ call s:initVariable("g:NERDTreeShowHidden", 0)
|
|||||||
call s:initVariable("g:NERDTreeShowLineNumbers", 0)
|
call s:initVariable("g:NERDTreeShowLineNumbers", 0)
|
||||||
call s:initVariable("g:NERDTreeSortDirs", 1)
|
call s:initVariable("g:NERDTreeSortDirs", 1)
|
||||||
call s:initVariable("g:NERDTreeDirArrows", !s:running_windows)
|
call s:initVariable("g:NERDTreeDirArrows", !s:running_windows)
|
||||||
|
call s:initVariable("g:NERDTreeCasadeOpenSingleChildDir", 0)
|
||||||
|
|
||||||
if !exists("g:NERDTreeSortOrder")
|
if !exists("g:NERDTreeSortOrder")
|
||||||
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
|
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
|
||||||
@ -1694,7 +1695,26 @@ function! s:TreeDirNode.open(...)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
"FUNCTION: TreeDirNode.openAlong([opts]) {{{3
|
||||||
|
"recursive open the dir if it has only one directory child.
|
||||||
|
"
|
||||||
|
"return the level of opened directories.
|
||||||
|
function! s:TreeDirNode.openAlong(...)
|
||||||
|
let opts = a:0 ? a:1 : {}
|
||||||
|
let level = 0
|
||||||
|
|
||||||
|
let node = self
|
||||||
|
while node.path.isDirectory
|
||||||
|
call node.open(opts)
|
||||||
|
let level += 1
|
||||||
|
if node.getVisibleChildCount() == 1
|
||||||
|
let node = node.getChildByIndex(0, 1)
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endwhile
|
||||||
|
return level
|
||||||
|
endfunction
|
||||||
" FUNCTION: TreeDirNode.openExplorer() {{{3
|
" FUNCTION: TreeDirNode.openExplorer() {{{3
|
||||||
" opens an explorer window for this node in the previous window (could be a
|
" opens an explorer window for this node in the previous window (could be a
|
||||||
" nerd tree or a netrw)
|
" nerd tree or a netrw)
|
||||||
@ -1857,10 +1877,13 @@ function! s:TreeDirNode.toggleOpen(...)
|
|||||||
if self.isOpen ==# 1
|
if self.isOpen ==# 1
|
||||||
call self.close()
|
call self.close()
|
||||||
else
|
else
|
||||||
call self.open(opts)
|
if g:NERDTreeCasadeOpenSingleChildDir == 0
|
||||||
|
call self.open(opts)
|
||||||
|
else
|
||||||
|
call self.openAlong(opts)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.transplantChild(newNode) {{{3
|
"FUNCTION: TreeDirNode.transplantChild(newNode) {{{3
|
||||||
"Replaces the child of this with the given node (where the child node's full
|
"Replaces the child of this with the given node (where the child node's full
|
||||||
"path matches a:newNode's fullpath). The search for the matching node is
|
"path matches a:newNode's fullpath). The search for the matching node is
|
||||||
|
Loading…
Reference in New Issue
Block a user