mirror of
https://github.com/preservim/nerdtree.git
synced 2024-10-18 22:00:21 +03:00
Merge branch 'master' of github.com:scrooloose/nerdtree
This commit is contained in:
commit
6a6ffe2ad6
@ -642,6 +642,12 @@ NERD tree. These options should be set in your vimrc.
|
|||||||
|'NERDTreeWinSize'| Sets the window size when the NERD tree is
|
|'NERDTreeWinSize'| Sets the window size when the NERD tree is
|
||||||
opened.
|
opened.
|
||||||
|
|
||||||
|
|'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*
|
3.2. Customisation details *NERDTreeOptionDetails*
|
||||||
|
|
||||||
@ -921,6 +927,30 @@ Default: 31.
|
|||||||
|
|
||||||
This option is used to change the size of the NERD tree when it is loaded.
|
This option is used to change the size of the NERD tree when it is loaded.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'NERDTreeMinimalUI'*
|
||||||
|
Values: 0 or 1
|
||||||
|
Default: 0
|
||||||
|
|
||||||
|
This options disables the 'Bookmarks' label 'Press ? for help' text. Use one
|
||||||
|
of the following lines to set this option: >
|
||||||
|
let NERDTreeMinimalUI=0
|
||||||
|
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*
|
4. The NERD tree API *NERDTreeAPI*
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ call s:initVariable("g:NERDTreeAutoCenter", 1)
|
|||||||
call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
|
call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
|
||||||
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
|
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
|
||||||
call s:initVariable("g:NERDTreeChDirMode", 0)
|
call s:initVariable("g:NERDTreeChDirMode", 0)
|
||||||
|
call s:initVariable("g:NERDTreeMinimalUI", 0)
|
||||||
if !exists("g:NERDTreeIgnore")
|
if !exists("g:NERDTreeIgnore")
|
||||||
let g:NERDTreeIgnore = ['\~$']
|
let g:NERDTreeIgnore = ['\~$']
|
||||||
endif
|
endif
|
||||||
@ -65,6 +66,7 @@ call s:initVariable("g:NERDTreeShowFiles", 1)
|
|||||||
call s:initVariable("g:NERDTreeShowHidden", 0)
|
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", 0)
|
||||||
|
|
||||||
if !exists("g:NERDTreeSortOrder")
|
if !exists("g:NERDTreeSortOrder")
|
||||||
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
|
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
|
||||||
@ -147,7 +149,7 @@ endif
|
|||||||
let s:NERDTreeBufName = 'NERD_tree_'
|
let s:NERDTreeBufName = 'NERD_tree_'
|
||||||
|
|
||||||
let s:tree_wid = 2
|
let s:tree_wid = 2
|
||||||
let s:tree_markup_reg = '^[ `|]*[\-+~]'
|
let s:tree_markup_reg = '^[ `|]*[\-+~▾▸ ]*'
|
||||||
let s:tree_up_dir_line = '.. (up a dir)'
|
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
|
"the number to add to the nerd tree buffer name to make the buf name unique
|
||||||
@ -1313,34 +1315,51 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
|
|||||||
"get all the leading spaces and vertical tree parts for this line
|
"get all the leading spaces and vertical tree parts for this line
|
||||||
if a:depth > 1
|
if a:depth > 1
|
||||||
for j in a:vertMap[0:-2]
|
for j in a:vertMap[0:-2]
|
||||||
|
if g:NERDTreeDirArrows
|
||||||
|
let treeParts = treeParts . ' '
|
||||||
|
else
|
||||||
if j ==# 1
|
if j ==# 1
|
||||||
let treeParts = treeParts . '| '
|
let treeParts = treeParts . '| '
|
||||||
else
|
else
|
||||||
let treeParts = treeParts . ' '
|
let treeParts = treeParts . ' '
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"get the last vertical tree part for this line which will be different
|
"get the last vertical tree part for this line which will be different
|
||||||
"if this node is the last child of its parent
|
"if this node is the last child of its parent
|
||||||
|
if !g:NERDTreeDirArrows
|
||||||
if a:isLastChild
|
if a:isLastChild
|
||||||
let treeParts = treeParts . '`'
|
let treeParts = treeParts . '`'
|
||||||
else
|
else
|
||||||
let treeParts = treeParts . '|'
|
let treeParts = treeParts . '|'
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
"smack the appropriate dir/file symbol on the line before the file/dir
|
"smack the appropriate dir/file symbol on the line before the file/dir
|
||||||
"name itself
|
"name itself
|
||||||
if self.path.isDirectory
|
if self.path.isDirectory
|
||||||
if self.isOpen
|
if self.isOpen
|
||||||
|
if g:NERDTreeDirArrows
|
||||||
|
let treeParts = treeParts . '▾ '
|
||||||
|
else
|
||||||
let treeParts = treeParts . '~'
|
let treeParts = treeParts . '~'
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
if g:NERDTreeDirArrows
|
||||||
|
let treeParts = treeParts . '▸ '
|
||||||
else
|
else
|
||||||
let treeParts = treeParts . '+'
|
let treeParts = treeParts . '+'
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
if g:NERDTreeDirArrows
|
||||||
|
let treeParts = treeParts . ' '
|
||||||
else
|
else
|
||||||
let treeParts = treeParts . '-'
|
let treeParts = treeParts . '-'
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
let line = treeParts . self.displayString()
|
let line = treeParts . self.displayString()
|
||||||
|
|
||||||
let output = output . line . "\n"
|
let output = output . line . "\n"
|
||||||
@ -2645,6 +2664,9 @@ function! s:initNerdTreeInPlace(dir)
|
|||||||
setlocal nu
|
setlocal nu
|
||||||
else
|
else
|
||||||
setlocal nonu
|
setlocal nonu
|
||||||
|
if v:version >= 703
|
||||||
|
setlocal nornu
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
iabc <buffer>
|
iabc <buffer>
|
||||||
@ -2881,6 +2903,9 @@ function! s:createTreeWin()
|
|||||||
setlocal nu
|
setlocal nu
|
||||||
else
|
else
|
||||||
setlocal nonu
|
setlocal nonu
|
||||||
|
if v:version >= 703
|
||||||
|
setlocal nornu
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
iabc <buffer>
|
iabc <buffer>
|
||||||
@ -2996,11 +3021,11 @@ function! s:dumpHelp()
|
|||||||
let @h=@h."\" :OpenBookmark <name>\n"
|
let @h=@h."\" :OpenBookmark <name>\n"
|
||||||
let @h=@h."\" :ClearBookmarks [<names>]\n"
|
let @h=@h."\" :ClearBookmarks [<names>]\n"
|
||||||
let @h=@h."\" :ClearAllBookmarks\n"
|
let @h=@h."\" :ClearAllBookmarks\n"
|
||||||
else
|
|
||||||
let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
|
|
||||||
endif
|
|
||||||
|
|
||||||
silent! put h
|
silent! put h
|
||||||
|
elseif g:NERDTreeMinimalUI == 0
|
||||||
|
let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
|
||||||
|
silent! put h
|
||||||
|
endif
|
||||||
|
|
||||||
let @h = old_h
|
let @h = old_h
|
||||||
endfunction
|
endfunction
|
||||||
@ -3067,10 +3092,12 @@ function! s:getPath(ln)
|
|||||||
return b:NERDTreeRoot.path
|
return b:NERDTreeRoot.path
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !g:NERDTreeDirArrows
|
||||||
" in case called from outside the tree
|
" in case called from outside the tree
|
||||||
if line !~# '^ *[|`]' || line =~# '^$'
|
if line !~# '^ *[|`▸▾ ]' || line =~# '^$'
|
||||||
return {}
|
return {}
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
if line ==# s:tree_up_dir_line
|
if line ==# s:tree_up_dir_line
|
||||||
return b:NERDTreeRoot.path.getParent()
|
return b:NERDTreeRoot.path.getParent()
|
||||||
@ -3125,7 +3152,13 @@ function! s:getTreeWinNum()
|
|||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:indentLevelFor(line) {{{2
|
"FUNCTION: s:indentLevelFor(line) {{{2
|
||||||
function! s:indentLevelFor(line)
|
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
|
endfunction
|
||||||
"FUNCTION: s:isTreeOpen() {{{2
|
"FUNCTION: s:isTreeOpen() {{{2
|
||||||
function! s:isTreeOpen()
|
function! s:isTreeOpen()
|
||||||
@ -3215,6 +3248,10 @@ function! s:putCursorOnBookmarkTable()
|
|||||||
throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
|
throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if g:NERDTreeMinimalUI
|
||||||
|
return cursor(1, 2)
|
||||||
|
endif
|
||||||
|
|
||||||
let rootNodeLine = s:TreeFileNode.GetRootLineNum()
|
let rootNodeLine = s:TreeFileNode.GetRootLineNum()
|
||||||
|
|
||||||
let line = 1
|
let line = 1
|
||||||
@ -3224,7 +3261,7 @@ function! s:putCursorOnBookmarkTable()
|
|||||||
throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table"
|
throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table"
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
call cursor(line, 0)
|
call cursor(line, 2)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:putCursorInTreeWin(){{{2
|
"FUNCTION: s:putCursorInTreeWin(){{{2
|
||||||
@ -3240,8 +3277,10 @@ endfunction
|
|||||||
"FUNCTION: s:renderBookmarks {{{2
|
"FUNCTION: s:renderBookmarks {{{2
|
||||||
function! s:renderBookmarks()
|
function! s:renderBookmarks()
|
||||||
|
|
||||||
|
if g:NERDTreeMinimalUI == 0
|
||||||
call setline(line(".")+1, ">----------Bookmarks----------")
|
call setline(line(".")+1, ">----------Bookmarks----------")
|
||||||
call cursor(line(".")+1, col("."))
|
call cursor(line(".")+1, col("."))
|
||||||
|
endif
|
||||||
|
|
||||||
for i in s:Bookmark.Bookmarks()
|
for i in s:Bookmark.Bookmarks()
|
||||||
call setline(line(".")+1, i.str())
|
call setline(line(".")+1, i.str())
|
||||||
@ -3268,16 +3307,20 @@ function! s:renderView()
|
|||||||
call s:dumpHelp()
|
call s:dumpHelp()
|
||||||
|
|
||||||
"delete the blank line before the help and add one after it
|
"delete the blank line before the help and add one after it
|
||||||
|
if g:NERDTreeMinimalUI == 0
|
||||||
call setline(line(".")+1, "")
|
call setline(line(".")+1, "")
|
||||||
call cursor(line(".")+1, col("."))
|
call cursor(line(".")+1, col("."))
|
||||||
|
endif
|
||||||
|
|
||||||
if b:NERDTreeShowBookmarks
|
if b:NERDTreeShowBookmarks
|
||||||
call s:renderBookmarks()
|
call s:renderBookmarks()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"add the 'up a dir' line
|
"add the 'up a dir' line
|
||||||
|
if !g:NERDTreeMinimalUI
|
||||||
call setline(line(".")+1, s:tree_up_dir_line)
|
call setline(line(".")+1, s:tree_up_dir_line)
|
||||||
call cursor(line(".")+1, col("."))
|
call cursor(line(".")+1, col("."))
|
||||||
|
endif
|
||||||
|
|
||||||
"draw the header line
|
"draw the header line
|
||||||
let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
|
let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
|
||||||
@ -3371,7 +3414,7 @@ function! s:setupSyntaxHighlighting()
|
|||||||
syn match NERDTreeFlag #\[RO\]#
|
syn match NERDTreeFlag #\[RO\]#
|
||||||
|
|
||||||
"highlighting for the .. (up dir) line at the top of the tree
|
"highlighting for the .. (up dir) line at the top of the tree
|
||||||
execute "syn match NERDTreeUp #". s:tree_up_dir_line ."#"
|
execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
|
||||||
|
|
||||||
"highlighting for the ~/+ symbols for the directory nodes
|
"highlighting for the ~/+ symbols for the directory nodes
|
||||||
syn match NERDTreeClosable #\~\<#
|
syn match NERDTreeClosable #\~\<#
|
||||||
@ -3402,7 +3445,7 @@ function! s:setupSyntaxHighlighting()
|
|||||||
"highlighing for directory nodes and file nodes
|
"highlighing for directory nodes and file nodes
|
||||||
syn match NERDTreeDirSlash #/#
|
syn match NERDTreeDirSlash #/#
|
||||||
syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable
|
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 NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
|
syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
|
||||||
syn match NERDTreeCWD #^/.*$#
|
syn match NERDTreeCWD #^/.*$#
|
||||||
|
Loading…
Reference in New Issue
Block a user