mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-23 01:04:07 +08:00
Make tree style (|+~ or arrows) configurable
This commit is contained in:
parent
867de91643
commit
8accb0978e
|
@ -642,6 +642,9 @@ NERD tree. These options should be set in your vimrc.
|
|||
|'NERDTreeWinSize'| Sets the window size when the NERD tree is
|
||||
opened.
|
||||
|
||||
|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of
|
||||
+ ~ chars when displaying directories.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.2. Customisation details *NERDTreeOptionDetails*
|
||||
|
||||
|
@ -921,6 +924,19 @@ Default: 31.
|
|||
|
||||
This option is used to change the size of the NERD tree when it is loaded.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'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*
|
||||
|
||||
|
|
|
@ -65,6 +65,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$', '\~$']
|
||||
|
@ -147,7 +148,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
|
||||
|
@ -1313,20 +1314,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]
|
||||
let treeParts = treeParts . ' '
|
||||
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 !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()
|
||||
|
||||
|
@ -3054,10 +3085,12 @@ function! s:getPath(ln)
|
|||
return b:NERDTreeRoot.path
|
||||
endif
|
||||
|
||||
" in case called from outside the tree
|
||||
" if line !~# '^ *[|`▸▾ ]' || line =~# '^$'
|
||||
" return {}
|
||||
" endif
|
||||
if !g:NERDTreeDirArrows
|
||||
" in case called from outside the tree
|
||||
if line !~# '^ *[|`▸▾ ]' || line =~# '^$'
|
||||
return {}
|
||||
endif
|
||||
endif
|
||||
|
||||
if line ==# s:tree_up_dir_line
|
||||
return b:NERDTreeRoot.path.getParent()
|
||||
|
|
Loading…
Reference in New Issue
Block a user