mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated plugins
This commit is contained in:
@ -255,6 +255,7 @@ function! s:findAndRevealPath(pathStr)
|
||||
endif
|
||||
|
||||
try
|
||||
let l:pathStr = g:NERDTreePath.Resolve(l:pathStr)
|
||||
let l:pathObj = g:NERDTreePath.New(l:pathStr)
|
||||
catch /^NERDTree.InvalidArgumentsError/
|
||||
call nerdtree#echoWarning('invalid path')
|
||||
@ -524,10 +525,17 @@ endfunction
|
||||
" Reloads the current root. All nodes below this will be lost and the root dir
|
||||
" will be reloaded.
|
||||
function! s:refreshRoot()
|
||||
if !g:NERDTree.IsOpen()
|
||||
return
|
||||
endif
|
||||
call nerdtree#echo("Refreshing the root node. This could take a while...")
|
||||
|
||||
let l:curWin = winnr()
|
||||
call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w")
|
||||
call b:NERDTree.root.refresh()
|
||||
call b:NERDTree.render()
|
||||
redraw
|
||||
call nerdtree#exec(l:curWin . "wincmd w")
|
||||
call nerdtree#echo("Refreshing the root node. This could take a while... DONE")
|
||||
endfunction
|
||||
|
||||
@ -554,6 +562,7 @@ function! nerdtree#ui_glue#setupCommands()
|
||||
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('<args>')
|
||||
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
|
||||
command! -n=? -complete=file -bar NERDTreeFind call s:findAndRevealPath('<args>')
|
||||
command! -n=0 -bar NERDTreeRefreshRoot call s:refreshRoot()
|
||||
command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()
|
||||
command! -n=0 -bar NERDTreeCWD call NERDTreeCWD()
|
||||
endfunction
|
||||
|
@ -145,6 +145,9 @@ The following features and functionality are provided by the NERD tree:
|
||||
Change the NERDTree root to the current working directory. If no
|
||||
NERDTree exists for this tab, a new one is opened.
|
||||
|
||||
:NERDTreeRefreshRoot *:NERDTreeRefreshRoot*
|
||||
Refreshes the NERD tree root node.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2. Bookmarks *NERDTreeBookmarks*
|
||||
|
||||
@ -992,17 +995,33 @@ appended to the array.
|
||||
|
||||
The regex '\/$' should be used to match directory nodes.
|
||||
|
||||
A special flag can be used to sort by the modification timestamps of files and
|
||||
directories. It is either '[[timestamp]]' for ascending, or '[[-timestamp]]'
|
||||
for descending. If placed at the beginning of the list, files and directories
|
||||
are sorted by timestamp, and then by the remaining items in the sort order
|
||||
list. If this flag is in any other position of the list, timestamp sorting is
|
||||
done secondarily. See examples 4, 5, and 6 below.
|
||||
|
||||
After this sorting is done, the files in each group are sorted alphabetically.
|
||||
|
||||
Other examples: >
|
||||
(1) ['*', '\/$']
|
||||
(2) []
|
||||
(3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$']
|
||||
(4) ['[[timestamp]]']
|
||||
(5) ['\/$', '*', '[[-timestamp]]']
|
||||
(6) ['\.md$', '\.c$', '[[-timestamp]]', '*']
|
||||
<
|
||||
1. Directories will appear last, everything else will appear above.
|
||||
2. Everything will simply appear in alphabetical order.
|
||||
3. Dirs will appear first, then ruby and php. Swap files, bak files and vim
|
||||
backup files will appear last with everything else preceding them.
|
||||
4. All files and directories are sorted by timestamp, oldest first. If any
|
||||
files have identical timestamps, they are sorted alphabetically.
|
||||
5. Directories are first, newest to oldest, then everything else, newest to
|
||||
oldest.
|
||||
6. Markdown files first, followed by C source files, then everything else.
|
||||
Each group is shown newest to oldest.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeStatusline'*
|
||||
@ -1014,7 +1033,7 @@ Defines the value for the |'statusline'| setting in NERDTree windows.
|
||||
Note: The setting is actually applied using |:let-&|, not |:set|, so
|
||||
escaping spaces is not necessary.
|
||||
|
||||
Setting this option to -1 will will deactivate it so that your global
|
||||
Setting this option to -1 will deactivate it so that your global
|
||||
|'statusline'| setting is used.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
@ -39,10 +39,10 @@ endfunction
|
||||
|
||||
" FUNCTION: Path.cacheDisplayString() {{{1
|
||||
function! s:Path.cacheDisplayString() abort
|
||||
let self.cachedDisplayString = self.getLastPathComponent(1)
|
||||
let self.cachedDisplayString = g:NERDTreeNodeDelimiter . self.getLastPathComponent(1)
|
||||
|
||||
if self.isExecutable
|
||||
let self.cachedDisplayString = self.cachedDisplayString . '*'
|
||||
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . '*'
|
||||
endif
|
||||
|
||||
let self._bookmarkNames = []
|
||||
@ -52,15 +52,24 @@ function! s:Path.cacheDisplayString() abort
|
||||
endif
|
||||
endfor
|
||||
if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks == 1
|
||||
let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}'
|
||||
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' {' . join(self._bookmarkNames) . '}'
|
||||
endif
|
||||
|
||||
if self.isSymLink
|
||||
let self.cachedDisplayString .= ' -> ' . self.symLinkDest
|
||||
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' -> ' . self.symLinkDest
|
||||
endif
|
||||
|
||||
if self.isReadOnly
|
||||
let self.cachedDisplayString .= ' ['.g:NERDTreeGlyphReadOnly.']'
|
||||
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' ['.g:NERDTreeGlyphReadOnly.']'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path.addDelimiter() {{{1
|
||||
function! s:Path.addDelimiter(line)
|
||||
if a:line =~# '\(.*' . g:NERDTreeNodeDelimiter . '\)\{2}'
|
||||
return a:line
|
||||
else
|
||||
return a:line . g:NERDTreeNodeDelimiter
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -392,7 +401,17 @@ endfunction
|
||||
" FUNCTION: Path.getSortKey() {{{1
|
||||
" returns a key used in compare function for sorting
|
||||
function! s:Path.getSortKey()
|
||||
if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder
|
||||
let l:ascending = index(g:NERDTreeSortOrder,'[[timestamp]]')
|
||||
let l:descending = index(g:NERDTreeSortOrder,'[[-timestamp]]')
|
||||
if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder || l:ascending >= 0 || l:descending >= 0
|
||||
let self._sortKey = [self.getSortOrderIndex()]
|
||||
|
||||
if l:descending >= 0
|
||||
call insert(self._sortKey, -getftime(self.str()), l:descending == 0 ? 0 : len(self._sortKey))
|
||||
elseif l:ascending >= 0
|
||||
call insert(self._sortKey, getftime(self.str()), l:ascending == 0 ? 0 : len(self._sortKey))
|
||||
endif
|
||||
|
||||
let path = self.getLastPathComponent(1)
|
||||
if !g:NERDTreeSortHiddenFirst
|
||||
let path = substitute(path, '^[._]', '', '')
|
||||
@ -400,13 +419,9 @@ function! s:Path.getSortKey()
|
||||
if !g:NERDTreeCaseSensitiveSort
|
||||
let path = tolower(path)
|
||||
endif
|
||||
if !g:NERDTreeNaturalSort
|
||||
let self._sortKey = [self.getSortOrderIndex(), path]
|
||||
else
|
||||
let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path)
|
||||
endif
|
||||
endif
|
||||
|
||||
call extend(self._sortKey, (g:NERDTreeNaturalSort ? self._splitChunks(path) : [path]))
|
||||
endif
|
||||
return self._sortKey
|
||||
endfunction
|
||||
|
||||
|
@ -99,7 +99,8 @@ function! s:TreeDirNode.displayString()
|
||||
let l:label = ''
|
||||
let l:cascade = self.getCascade()
|
||||
for l:dirNode in l:cascade
|
||||
let l:label .= l:dirNode.path.displayString()
|
||||
let l:next = l:dirNode.path.displayString()
|
||||
let l:label .= l:label == '' ? l:next : substitute(l:next,'^.','','')
|
||||
endfor
|
||||
|
||||
" Select the appropriate open/closed status indicator symbol.
|
||||
@ -304,9 +305,11 @@ function! s:TreeDirNode._glob(pattern, all)
|
||||
for l:file in l:globList
|
||||
let l:tail = fnamemodify(l:file, ':t')
|
||||
|
||||
" Double the modifier if only a separator was stripped.
|
||||
" If l:file has a trailing slash, then its :tail will be ''. Use
|
||||
" :h to drop the slash and the empty string after it; then use :t
|
||||
" to get the directory name.
|
||||
if l:tail == ''
|
||||
let l:tail = fnamemodify(l:file, ':t:t')
|
||||
let l:tail = fnamemodify(l:file, ':h:t')
|
||||
endif
|
||||
|
||||
if l:tail == '.' || l:tail == '..'
|
||||
|
@ -180,7 +180,7 @@ function! s:TreeFileNode.GetSelected()
|
||||
endif
|
||||
|
||||
return b:NERDTree.root.findNode(l:path)
|
||||
catch /^NERDTree/
|
||||
catch
|
||||
return {}
|
||||
endtry
|
||||
endfunction
|
||||
@ -242,7 +242,7 @@ endfunction
|
||||
|
||||
" FUNCTION: TreeFileNode.openInNewTab(options) {{{1
|
||||
function! s:TreeFileNode.openInNewTab(options)
|
||||
echomsg 'TreeFileNode.openInNewTab is deprecated'
|
||||
call nerdtree#deprecated('TreeFileNode.openinNewTab', 'is deprecated, use .open() instead.')
|
||||
call self.open(extend({'where': 't'}, a:options))
|
||||
endfunction
|
||||
|
||||
|
@ -300,7 +300,7 @@ endfunction
|
||||
|
||||
" FUNCTION: s:UI.MarkupReg() {{{1
|
||||
function! s:UI.MarkupReg()
|
||||
return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)'
|
||||
return '^ *['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']\? '
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI._renderBookmarks {{{1
|
||||
@ -363,30 +363,13 @@ function! s:UI.setShowHidden(val)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI._stripMarkup(line){{{1
|
||||
" returns the given line with all the tree parts stripped off
|
||||
" find the filename in the given line, and return it.
|
||||
"
|
||||
" Args:
|
||||
" line: the subject line
|
||||
function! s:UI._stripMarkup(line)
|
||||
let line = a:line
|
||||
" remove the tree parts and the leading space
|
||||
let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","")
|
||||
|
||||
" strip off any read only flag
|
||||
let line = substitute (line, ' \['.g:NERDTreeGlyphReadOnly.'\]', "","")
|
||||
|
||||
" strip off any bookmark flags
|
||||
let line = substitute (line, ' {[^}]*}', "","")
|
||||
|
||||
" strip off any executable flags
|
||||
let line = substitute (line, '*\ze\($\| \)', "","")
|
||||
|
||||
" strip off any generic flags
|
||||
let line = substitute (line, '\[[^]]*\]', "","")
|
||||
|
||||
let line = substitute (line,' -> .*',"","") " remove link to
|
||||
|
||||
return line
|
||||
let l:line = substitute(a:line, '^.\{-}' . g:NERDTreeNodeDelimiter, '', '')
|
||||
return substitute(l:line, g:NERDTreeNodeDelimiter.'.*$', '', '')
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI.render() {{{1
|
||||
|
@ -83,31 +83,32 @@ function! s:promptToDelBuffer(bufnum, msg)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:promptToRenameBuffer(bufnum, msg){{{1
|
||||
"prints out the given msg and, if the user responds by pushing 'y' then the
|
||||
"buffer with the given bufnum is replaced with a new one
|
||||
"FUNCTION: s:renameBuffer(bufNum, newNodeName, isDirectory){{{1
|
||||
"The buffer with the given bufNum is replaced with a new one
|
||||
"
|
||||
"Args:
|
||||
"bufnum: the buffer that may be deleted
|
||||
"msg: a message that will be echoed to the user asking them if they wish to
|
||||
" del the buffer
|
||||
function! s:promptToRenameBuffer(bufnum, msg, newFileName)
|
||||
echo a:msg
|
||||
if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y'
|
||||
let quotedFileName = fnameescape(a:newFileName)
|
||||
" 1. ensure that a new buffer is loaded
|
||||
exec "badd " . quotedFileName
|
||||
" 2. ensure that all windows which display the just deleted filename
|
||||
" display a buffer for a new filename.
|
||||
let s:originalTabNumber = tabpagenr()
|
||||
let s:originalWindowNumber = winnr()
|
||||
let editStr = g:NERDTreePath.New(a:newFileName).str({'format': 'Edit'})
|
||||
exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':e! " . editStr . "' | endif"
|
||||
exec "tabnext " . s:originalTabNumber
|
||||
exec s:originalWindowNumber . "wincmd w"
|
||||
" 3. We don't need a previous buffer anymore
|
||||
exec "bwipeout! " . a:bufnum
|
||||
"bufNum: the buffer that may be deleted
|
||||
"newNodeName: the name given to the renamed node
|
||||
"isDirectory: determines how to do the create the new filenames
|
||||
function! s:renameBuffer(bufNum, newNodeName, isDirectory)
|
||||
if a:isDirectory
|
||||
let quotedFileName = fnameescape(a:newNodeName . '/' . fnamemodify(bufname(a:bufNum),':t'))
|
||||
let editStr = g:NERDTreePath.New(a:newNodeName . '/' . fnamemodify(bufname(a:bufNum),':t')).str({'format': 'Edit'})
|
||||
else
|
||||
let quotedFileName = fnameescape(a:newNodeName)
|
||||
let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'})
|
||||
endif
|
||||
" 1. ensure that a new buffer is loaded
|
||||
exec "badd " . quotedFileName
|
||||
" 2. ensure that all windows which display the just deleted filename
|
||||
" display a buffer for a new filename.
|
||||
let s:originalTabNumber = tabpagenr()
|
||||
let s:originalWindowNumber = winnr()
|
||||
exec "tabdo windo if winbufnr(0) == " . a:bufNum . " | exec ':e! " . editStr . "' | endif"
|
||||
exec "tabnext " . s:originalTabNumber
|
||||
exec s:originalWindowNumber . "wincmd w"
|
||||
" 3. We don't need a previous buffer anymore
|
||||
exec "bwipeout! " . a:bufNum
|
||||
endfunction
|
||||
"FUNCTION: NERDTreeAddNode(){{{1
|
||||
function! NERDTreeAddNode()
|
||||
@ -128,6 +129,9 @@ function! NERDTreeAddNode()
|
||||
let parentNode = b:NERDTree.root.findNode(newPath.getParent())
|
||||
|
||||
let newTreeNode = g:NERDTreeFileNode.New(newPath, b:NERDTree)
|
||||
" Emptying g:NERDTreeOldSortOrder forces the sort to
|
||||
" recalculate the cached sortKey so nodes sort correctly.
|
||||
let g:NERDTreeOldSortOrder = []
|
||||
if empty(parentNode)
|
||||
call b:NERDTree.root.refresh()
|
||||
call b:NERDTree.render()
|
||||
@ -155,17 +159,33 @@ function! NERDTreeMoveNode()
|
||||
endif
|
||||
|
||||
try
|
||||
let bufnum = bufnr("^".curNode.path.str()."$")
|
||||
if curNode.path.isDirectory
|
||||
let l:openBuffers = filter(range(1,bufnr("$")),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# curNode.path.str() . "/.*"')
|
||||
else
|
||||
let l:openBuffers = filter(range(1,bufnr("$")),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()')
|
||||
endif
|
||||
|
||||
call curNode.rename(newNodePath)
|
||||
" Emptying g:NERDTreeOldSortOrder forces the sort to
|
||||
" recalculate the cached sortKey so nodes sort correctly.
|
||||
let g:NERDTreeOldSortOrder = []
|
||||
call b:NERDTree.root.refresh()
|
||||
call NERDTreeRender()
|
||||
|
||||
"if the node is open in a buffer, ask the user if they want to
|
||||
"close that buffer
|
||||
if bufnum != -1
|
||||
let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Replace this buffer with the new file? (yN)"
|
||||
call s:promptToRenameBuffer(bufnum, prompt, newNodePath)
|
||||
" If the file node is open, or files under the directory node are
|
||||
" open, ask the user if they want to replace the file(s) with the
|
||||
" renamed files.
|
||||
if !empty(l:openBuffers)
|
||||
if curNode.path.isDirectory
|
||||
echo "\nDirectory renamed.\n\nFiles with the old directory name are open in buffers " . join(l:openBuffers, ', ') . ". Replace these buffers with the new files? (yN)"
|
||||
else
|
||||
echo "\nFile renamed.\n\nThe old file is open in buffer " . l:openBuffers[0] . ". Replace this buffer with the new file? (yN)"
|
||||
endif
|
||||
if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y'
|
||||
for bufNum in l:openBuffers
|
||||
call s:renameBuffer(bufNum, newNodePath, curNode.path.isDirectory)
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
|
||||
call curNode.putCursorHere(1, 0)
|
||||
@ -226,9 +246,9 @@ function! NERDTreeListNode()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
if !empty(treenode)
|
||||
let s:uname = system("uname")
|
||||
let stat_cmd = 'stat -c "%s" '
|
||||
|
||||
if s:uname =~? "Darwin"
|
||||
let stat_cmd = 'stat -c "%s" '
|
||||
|
||||
if s:uname =~? "Darwin"
|
||||
let stat_cmd = 'stat -f "%z" '
|
||||
endif
|
||||
|
||||
@ -248,33 +268,13 @@ function! NERDTreeListNodeWin32()
|
||||
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||
|
||||
if !empty(l:node)
|
||||
|
||||
let l:save_shell = &shell
|
||||
set shell&
|
||||
|
||||
if exists('+shellslash')
|
||||
let l:save_shellslash = &shellslash
|
||||
set noshellslash
|
||||
endif
|
||||
|
||||
let l:command = 'DIR /Q '
|
||||
\ . shellescape(l:node.path.str())
|
||||
\ . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'
|
||||
|
||||
let l:metadata = split(system(l:command), "\n")
|
||||
|
||||
if v:shell_error == 0
|
||||
call nerdtree#echo(l:metadata[0])
|
||||
else
|
||||
call nerdtree#echoError('shell command failed')
|
||||
endif
|
||||
|
||||
let &shell = l:save_shell
|
||||
|
||||
if exists('l:save_shellslash')
|
||||
let &shellslash = l:save_shellslash
|
||||
endif
|
||||
|
||||
let l:path = l:node.path.str()
|
||||
call nerdtree#echo(printf("%s:%s MOD:%s BYTES:%d PERMISSIONS:%s",
|
||||
\ toupper(getftype(l:path)),
|
||||
\ fnamemodify(l:path, ':t'),
|
||||
\ strftime("%c", getftime(l:path)),
|
||||
\ getfsize(l:path),
|
||||
\ getfperm(l:path)))
|
||||
return
|
||||
endif
|
||||
|
||||
@ -303,6 +303,9 @@ function! NERDTreeCopyNode()
|
||||
if confirmed
|
||||
try
|
||||
let newNode = currentNode.copy(newNodePath)
|
||||
" Emptying g:NERDTreeOldSortOrder forces the sort to
|
||||
" recalculate the cached sortKey so nodes sort correctly.
|
||||
let g:NERDTreeOldSortOrder = []
|
||||
if empty(newNode)
|
||||
call b:NERDTree.root.refresh()
|
||||
call b:NERDTree.render()
|
||||
|
@ -86,6 +86,9 @@ let g:NERDTreeOldSortOrder = []
|
||||
|
||||
call s:initVariable("g:NERDTreeGlyphReadOnly", "RO")
|
||||
|
||||
" ASCII 160: non-breaking space used to delimit items in the tree's nodes.
|
||||
call s:initVariable("g:NERDTreeNodeDelimiter", "\u00a0")
|
||||
|
||||
if !exists('g:NERDTreeStatusline')
|
||||
|
||||
"the exists() crap here is a hack to stop vim spazzing out when
|
||||
|
@ -36,6 +36,15 @@ exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains
|
||||
syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile
|
||||
syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir
|
||||
|
||||
"highlighing to conceal the delimiter around the file/dir name
|
||||
if has("conceal")
|
||||
exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# conceal containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeExecFile,NERDTreeRO,NERDTreeDir'
|
||||
setlocal conceallevel=3 concealcursor=nvic
|
||||
else
|
||||
exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeExecFile,NERDTreeRO,NERDTreeDir'
|
||||
hi! link NERDTreeNodeDelimiters Ignore
|
||||
endif
|
||||
|
||||
syn match NERDTreeCWD #^[</].*$#
|
||||
|
||||
"highlighting for bookmarks
|
||||
|
Reference in New Issue
Block a user