Merge branch 'disable-cascade' of git://github.com/juanibiapina/nerdtree into juanibiapina-disable-cascade

This commit is contained in:
Phil Runninger
2016-09-08 01:02:17 -04:00
3 changed files with 31 additions and 25 deletions

View File

@@ -671,6 +671,10 @@ NERD tree. These options should be set in your vimrc.
|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and
'Press ? for help' text.
|'NERDTreeCascadeSingleChildDir'|
Collapses on the same line directories that
have only one child directory.
|'NERDTreeCascadeOpenSingleChildDir'|
Cascade open while selected directory has only
one child that also is a directory.
@@ -986,6 +990,17 @@ of the following lines to set this option: >
let NERDTreeMinimalUI=1
<
------------------------------------------------------------------------------
*'NERDTreeCascadeSingleChildDir'*
Values: 0 or 1
Default: 1.
When displaying dir nodes, this option tells NERDTree to collapse dirs that
have only one child. Use one of the follow lines to set this option: >
let NERDTreeCascadeSingleChildDir=0
let NERDTreeCascadeSingleChildDir=1
<
------------------------------------------------------------------------------
*'NERDTreeCascadeOpenSingleChildDir'*
Values: 0 or 1

View File

@@ -117,28 +117,14 @@ endfunction
"FUNCTION: TreeDirNode.getCascade() {{{1
"Return an array of dir nodes (starting from self) that can be cascade opened.
function! s:TreeDirNode.getCascade()
let rv = [self]
let node = self
while 1
let vc = node.getVisibleChildren()
if len(vc) != 1
break
if !self.isCascadable()
return [self]
endif
let vc = self.getVisibleChildren()
let visChild = vc[0]
"TODO: optimize
if !visChild.path.isDirectory
break
endif
call add(rv, visChild)
let node = visChild
endwhile
return rv
return [self] + visChild.getCascade()
endfunction
"FUNCTION: TreeDirNode.getChildCount() {{{1
@@ -264,6 +250,10 @@ endfunction
"FUNCTION: TreeDirNode.isCascadable() {{{1
"true if this dir has only one visible child - which is also a dir
function! s:TreeDirNode.isCascadable()
if g:NERDTreeCascadeSingleChildDir == 0
return 0
endif
let c = self.getVisibleChildren()
return len(c) == 1 && c[0].path.isDirectory
endfunction

View File

@@ -75,6 +75,7 @@ else
call s:initVariable("g:NERDTreeDirArrowCollapsible", "~")
endif
call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1)
call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1)
if !exists("g:NERDTreeSortOrder")
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']