Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/scrooloose/nerdtree
Browse files Browse the repository at this point in the history
Conflicts:
	doc/NERD_tree.txt
  • Loading branch information
camthompson committed Feb 28, 2011
2 parents 999ba49 + 21bd141 commit b9e970d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 17 deletions.
16 changes: 16 additions & 0 deletions doc/NERD_tree.txt
Expand Up @@ -645,6 +645,9 @@ NERD tree. These options should be set in your vimrc.
|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and
'Press ? for help' text.

|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of
+ ~ chars when displaying directories.

------------------------------------------------------------------------------
3.2. Customisation details *NERDTreeOptionDetails*

Expand Down Expand Up @@ -935,6 +938,19 @@ of the following lines to set this option: >
let NERDTreeMinimalUI=1
<

------------------------------------------------------------------------------
*'NERDTreeDirArrows'*
Values: 0 or 1
Default: 0.

This option is used to change the default look of directory nodes displayed in
the tree. When set to 0 it shows old-school bars (|), + and ~ chars. If set to
1 it shows right and down arrows. Use one of the follow lines to set this
option: >
let NERDTreeDirArrows=0
let NERDTreeDirArrows=1
<

==============================================================================
4. The NERD tree API *NERDTreeAPI*

Expand Down
60 changes: 43 additions & 17 deletions plugin/NERD_tree.vim
Expand Up @@ -66,6 +66,7 @@ call s:initVariable("g:NERDTreeShowFiles", 1)
call s:initVariable("g:NERDTreeShowHidden", 0)
call s:initVariable("g:NERDTreeShowLineNumbers", 0)
call s:initVariable("g:NERDTreeSortDirs", 1)
call s:initVariable("g:NERDTreeDirArrows", 0)

if !exists("g:NERDTreeSortOrder")
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
Expand Down Expand Up @@ -148,7 +149,7 @@ endif
let s:NERDTreeBufName = 'NERD_tree_'

let s:tree_wid = 2
let s:tree_markup_reg = '^[ `|]*[\-+~]'
let s:tree_markup_reg = '^[ `|]*[\-+~▾▸ ]*'
let s:tree_up_dir_line = '.. (up a dir)'

"the number to add to the nerd tree buffer name to make the buf name unique
Expand Down Expand Up @@ -1314,33 +1315,50 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
"get all the leading spaces and vertical tree parts for this line
if a:depth > 1
for j in a:vertMap[0:-2]
if j ==# 1
let treeParts = treeParts . '| '
else
if g:NERDTreeDirArrows
let treeParts = treeParts . ' '
else
if j ==# 1
let treeParts = treeParts . '| '
else
let treeParts = treeParts . ' '
endif
endif
endfor
endif

"get the last vertical tree part for this line which will be different
"if this node is the last child of its parent
if a:isLastChild
let treeParts = treeParts . '`'
else
let treeParts = treeParts . '|'
if !g:NERDTreeDirArrows
if a:isLastChild
let treeParts = treeParts . '`'
else
let treeParts = treeParts . '|'
endif
endif


"smack the appropriate dir/file symbol on the line before the file/dir
"name itself
if self.path.isDirectory
if self.isOpen
let treeParts = treeParts . '~'
if g:NERDTreeDirArrows
let treeParts = treeParts . ''
else
let treeParts = treeParts . '~'
endif
else
let treeParts = treeParts . '+'
if g:NERDTreeDirArrows
let treeParts = treeParts . ''
else
let treeParts = treeParts . '+'
endif
endif
else
let treeParts = treeParts . '-'
if g:NERDTreeDirArrows
let treeParts = treeParts . ' '
else
let treeParts = treeParts . '-'
endif
endif
let line = treeParts . self.displayString()

Expand Down Expand Up @@ -3068,9 +3086,11 @@ function! s:getPath(ln)
return b:NERDTreeRoot.path
endif

" in case called from outside the tree
if line !~# '^ *[|`]' || line =~# '^$'
return {}
if !g:NERDTreeDirArrows
" in case called from outside the tree
if line !~# '^ *[|`▸▾ ]' || line =~# '^$'
return {}
endif
endif

if line ==# s:tree_up_dir_line
Expand Down Expand Up @@ -3126,7 +3146,13 @@ function! s:getTreeWinNum()
endfunction
"FUNCTION: s:indentLevelFor(line) {{{2
function! s:indentLevelFor(line)
return match(a:line, '[^ \-+~`|]') / s:tree_wid
let level = match(a:line, '[^ \-+~▸▾`|]') / s:tree_wid
" check if line includes arrows
if match(a:line, '[▸▾]') > -1
" decrement level as arrow uses 3 ascii chars
let level = level - 1
endif
return level
endfunction
"FUNCTION: s:isTreeOpen() {{{2
function! s:isTreeOpen()
Expand Down Expand Up @@ -3407,7 +3433,7 @@ function! s:setupSyntaxHighlighting()
"highlighing for directory nodes and file nodes
syn match NERDTreeDirSlash #/#
syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable
syn match NERDTreeExecFile #[|`]-.*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark
syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark
syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
syn match NERDTreeCWD #^/.*$#
Expand Down

0 comments on commit b9e970d

Please sign in to comment.