mirror of
https://github.com/amix/vimrc
synced 2025-07-09 10:45:00 +08:00
Merge remote-tracking branch 'refs/remotes/upstream/master'
Conflicts: sources_non_forked/ale/autoload/ale.vim sources_non_forked/lightline.vim/doc/lightline.txt sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md sources_non_forked/nerdtree/autoload/nerdtree.vim sources_non_forked/nerdtree/plugin/NERD_tree.vim sources_non_forked/vim-fugitive/autoload/fugitive.vim sources_non_forked/vim-fugitive/doc/fugitive.txt
This commit is contained in:
@ -28,7 +28,9 @@ endfunction
|
||||
|
||||
" FUNCTION: s:Creator._broadcastInitEvent() {{{1
|
||||
function! s:Creator._broadcastInitEvent()
|
||||
silent doautocmd User NERDTreeInit
|
||||
if exists('#User#NERDTreeInit')
|
||||
doautocmd User NERDTreeInit
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:Creator.BufNamePrefix() {{{1
|
||||
@ -170,6 +172,7 @@ function! s:Creator.createMirror()
|
||||
let t:NERDTreeBufName = bufferName
|
||||
call self._createTreeWin()
|
||||
exec 'buffer ' . bufferName
|
||||
call b:NERDTree.ui.restoreScreenState()
|
||||
if !&hidden
|
||||
call b:NERDTree.render()
|
||||
endif
|
||||
@ -247,9 +250,13 @@ function! s:Creator._pathForString(str)
|
||||
|
||||
"hack to get an absolute path if a relative path is given
|
||||
if dir =~# '^\.'
|
||||
let dir = getcwd() . g:NERDTreePath.Slash() . dir
|
||||
let dir = getcwd() . nerdtree#slash() . dir
|
||||
endif
|
||||
|
||||
"hack to prevent removing slash if dir is the root of the file system.
|
||||
if dir !=# '/'
|
||||
let dir = g:NERDTreePath.Resolve(dir)
|
||||
endif
|
||||
let dir = g:NERDTreePath.Resolve(dir)
|
||||
|
||||
try
|
||||
let path = g:NERDTreePath.New(dir)
|
||||
@ -366,7 +373,7 @@ function! s:Creator.toggleTabTree(dir)
|
||||
if g:NERDTree.ExistsForTab()
|
||||
if !g:NERDTree.IsOpen()
|
||||
call self._createTreeWin()
|
||||
if !empty(a:dir)
|
||||
if !empty(a:dir) && a:dir !=# b:NERDTree.root.path.str()
|
||||
call self.createTabTree(a:dir)
|
||||
elseif !&hidden
|
||||
call b:NERDTree.render()
|
||||
|
@ -27,7 +27,9 @@ function! s:NERDTree.changeRoot(node)
|
||||
call self.render()
|
||||
call self.root.putCursorHere(0, 0)
|
||||
|
||||
silent doautocmd User NERDTreeNewRoot
|
||||
if exists('#User#NERDTreeNewRoot')
|
||||
doautocmd User NERDTreeNewRoot
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.Close() {{{1
|
||||
@ -96,9 +98,9 @@ endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.CursorToTreeWin(){{{1
|
||||
"Places the cursor in the nerd tree window
|
||||
function! s:NERDTree.CursorToTreeWin()
|
||||
function! s:NERDTree.CursorToTreeWin(...)
|
||||
call g:NERDTree.MustBeOpen()
|
||||
call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', 1)
|
||||
call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', a:0 >0 ? a:1 : 1)
|
||||
endfunction
|
||||
|
||||
" Function: s:NERDTree.ExistsForBuffer() {{{1
|
||||
|
@ -174,9 +174,8 @@ function! s:Opener._newSplit()
|
||||
|
||||
"resize the tree window if no other window was open before
|
||||
if onlyOneWin
|
||||
let size = exists('b:NERDTreeOldWindowSize') ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
|
||||
call nerdtree#exec('wincmd p', 1)
|
||||
call nerdtree#exec('silent '. splitMode .' resize '. size, 1)
|
||||
call nerdtree#exec('silent '. splitMode .' resize '. g:NERDTreeWinSize, 1)
|
||||
call nerdtree#exec('wincmd p', 0)
|
||||
endif
|
||||
|
||||
@ -195,7 +194,7 @@ function! s:Opener._newVSplit()
|
||||
endif
|
||||
|
||||
call nerdtree#exec('wincmd p', 1)
|
||||
call nerdtree#exec('vnew', 1)
|
||||
call nerdtree#exec('vsplit', 1)
|
||||
|
||||
let l:currentWindowNumber = winnr()
|
||||
|
||||
@ -219,7 +218,7 @@ endfunction
|
||||
|
||||
" FUNCTION: Opener._openFile() {{{1
|
||||
function! s:Opener._openFile()
|
||||
if !self._stay && !and(g:NERDTreeQuitOnOpen,1) && exists('b:NERDTreeZoomed') && b:NERDTreeZoomed
|
||||
if !self._stay && !nerdtree#and(g:NERDTreeQuitOnOpen,1) && exists('b:NERDTreeZoomed') && b:NERDTreeZoomed
|
||||
call b:NERDTree.ui.toggleZoom()
|
||||
endif
|
||||
|
||||
|
@ -25,10 +25,10 @@ function! s:Path.AbsolutePathFor(pathStr)
|
||||
if l:prependWorkingDir
|
||||
let l:result = getcwd()
|
||||
|
||||
if l:result[-1:] ==# s:Path.Slash()
|
||||
if l:result[-1:] == nerdtree#slash()
|
||||
let l:result = l:result . a:pathStr
|
||||
else
|
||||
let l:result = l:result . s:Path.Slash() . a:pathStr
|
||||
let l:result = l:result . nerdtree#slash() . a:pathStr
|
||||
endif
|
||||
endif
|
||||
|
||||
@ -99,50 +99,6 @@ function! s:Path.changeToDir()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path.compareTo() {{{1
|
||||
"
|
||||
" Compares this Path to the given path and returns 0 if they are equal, -1 if
|
||||
" this Path is 'less than' the given path, or 1 if it is 'greater'.
|
||||
"
|
||||
" Args:
|
||||
" path: the path object to compare this to
|
||||
"
|
||||
" Return:
|
||||
" 1, -1 or 0
|
||||
function! s:Path.compareTo(path)
|
||||
let thisPath = self.getLastPathComponent(1)
|
||||
let thatPath = a:path.getLastPathComponent(1)
|
||||
|
||||
"if the paths are the same then clearly we return 0
|
||||
if thisPath ==# thatPath
|
||||
return 0
|
||||
endif
|
||||
|
||||
let thisSS = self.getSortOrderIndex()
|
||||
let thatSS = a:path.getSortOrderIndex()
|
||||
|
||||
"compare the sort sequences, if they are different then the return
|
||||
"value is easy
|
||||
if thisSS < thatSS
|
||||
return -1
|
||||
elseif thisSS > thatSS
|
||||
return 1
|
||||
else
|
||||
if !g:NERDTreeSortHiddenFirst
|
||||
let thisPath = substitute(thisPath, '^[._]', '', '')
|
||||
let thatPath = substitute(thatPath, '^[._]', '', '')
|
||||
endif
|
||||
"if the sort sequences are the same then compare the paths
|
||||
"alphabetically
|
||||
let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath <? thatPath
|
||||
if pathCompare
|
||||
return -1
|
||||
else
|
||||
return 1
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path.Create(fullpath) {{{1
|
||||
"
|
||||
" Factory method.
|
||||
@ -199,7 +155,7 @@ function! s:Path.copy(dest)
|
||||
let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd)
|
||||
endif
|
||||
|
||||
let cmd = cmd_prefix . ' ' . escape(self.str(), self._escChars()) . ' ' . escape(a:dest, self._escChars())
|
||||
let cmd = cmd_prefix . ' ' . shellescape(self.str()) . ' ' . shellescape(a:dest)
|
||||
let success = system(cmd)
|
||||
if v:shell_error !=# 0
|
||||
throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'"
|
||||
@ -295,7 +251,10 @@ endfunction
|
||||
|
||||
" FUNCTION: Path.edit() {{{1
|
||||
function! s:Path.edit()
|
||||
exec 'edit ' . self.str({'format': 'Edit'})
|
||||
let l:bufname = self.str({'format': 'Edit'})
|
||||
if bufname('%') !=# l:bufname
|
||||
exec 'edit ' . l:bufname
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path.extractDriveLetter(fullpath) {{{1
|
||||
@ -329,7 +288,7 @@ function! s:Path._escChars()
|
||||
return " `\|\"#%&,?()\*^<>$"
|
||||
endif
|
||||
|
||||
return " \\`\|\"#%&,?()\*^<>[]$"
|
||||
return " \\`\|\"#%&,?()\*^<>[]{}$"
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path.getDir() {{{1
|
||||
@ -543,26 +502,36 @@ endfunction
|
||||
" return 1 if this path is somewhere above the given path in the filesystem.
|
||||
"
|
||||
" a:path should be a dir
|
||||
function! s:Path.isAncestor(path)
|
||||
if !self.isDirectory
|
||||
return 0
|
||||
endif
|
||||
|
||||
let this = self.str()
|
||||
let that = a:path.str()
|
||||
return stridx(that, this) ==# 0
|
||||
function! s:Path.isAncestor(child)
|
||||
return a:child.isUnder(self)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path.isUnder(path) {{{1
|
||||
" return 1 if this path is somewhere under the given path in the filesystem.
|
||||
function! s:Path.isUnder(path)
|
||||
if a:path.isDirectory ==# 0
|
||||
function! s:Path.isUnder(parent)
|
||||
if a:parent.isDirectory ==# 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let this = self.str()
|
||||
let that = a:path.str()
|
||||
return stridx(this, that . s:Path.Slash()) ==# 0
|
||||
if nerdtree#runningWindows() && a:parent.drive !=# self.drive
|
||||
return 0
|
||||
endif
|
||||
let l:this_count = len(self.pathSegments)
|
||||
if l:this_count ==# 0
|
||||
return 0
|
||||
endif
|
||||
let l:that_count = len(a:parent.pathSegments)
|
||||
if l:that_count ==# 0
|
||||
return 1
|
||||
endif
|
||||
if l:that_count >= l:this_count
|
||||
return 0
|
||||
endif
|
||||
for i in range(0, l:that_count-1)
|
||||
if self.pathSegments[i] !=# a:parent.pathSegments[i]
|
||||
return 0
|
||||
endif
|
||||
endfor
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path.JoinPathStrings(...) {{{1
|
||||
@ -601,23 +570,6 @@ function! s:Path.New(pathStr)
|
||||
return l:newPath
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path.Slash() {{{1
|
||||
" Return the path separator used by the underlying file system. Special
|
||||
" consideration is taken for the use of the 'shellslash' option on Windows
|
||||
" systems.
|
||||
function! s:Path.Slash()
|
||||
|
||||
if nerdtree#runningWindows()
|
||||
if exists('+shellslash') && &shellslash
|
||||
return '/'
|
||||
endif
|
||||
|
||||
return '\'
|
||||
endif
|
||||
|
||||
return '/'
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path.Resolve() {{{1
|
||||
" Invoke the vim resolve() function and return the result
|
||||
" This is necessary because in some versions of vim resolve() removes trailing
|
||||
@ -802,7 +754,7 @@ function! s:Path._strForEdit()
|
||||
|
||||
" On Windows, the drive letter may be removed by "fnamemodify()". Add it
|
||||
" back, if necessary.
|
||||
if nerdtree#runningWindows() && l:result[0] ==# s:Path.Slash()
|
||||
if nerdtree#runningWindows() && l:result[0] == nerdtree#slash()
|
||||
let l:result = self.drive . l:result
|
||||
endif
|
||||
|
||||
@ -817,14 +769,14 @@ endfunction
|
||||
|
||||
" FUNCTION: Path._strForGlob() {{{1
|
||||
function! s:Path._strForGlob()
|
||||
let lead = s:Path.Slash()
|
||||
let lead = nerdtree#slash()
|
||||
|
||||
"if we are running windows then slap a drive letter on the front
|
||||
if nerdtree#runningWindows()
|
||||
let lead = self.drive . '\'
|
||||
endif
|
||||
|
||||
let toReturn = lead . join(self.pathSegments, s:Path.Slash())
|
||||
let toReturn = lead . join(self.pathSegments, nerdtree#slash())
|
||||
|
||||
if !nerdtree#runningWindows()
|
||||
let toReturn = escape(toReturn, self._escChars())
|
||||
@ -836,7 +788,7 @@ endfunction
|
||||
" Return the absolute pathname associated with this Path object. The pathname
|
||||
" returned is appropriate for the underlying file system.
|
||||
function! s:Path._str()
|
||||
let l:separator = s:Path.Slash()
|
||||
let l:separator = nerdtree#slash()
|
||||
let l:leader = l:separator
|
||||
|
||||
if nerdtree#runningWindows()
|
||||
|
@ -104,16 +104,11 @@ function! s:TreeDirNode.displayString()
|
||||
endfor
|
||||
|
||||
" Select the appropriate open/closed status indicator symbol.
|
||||
if l:cascade[-1].isOpen
|
||||
let l:symbol = g:NERDTreeDirArrowCollapsible
|
||||
else
|
||||
let l:symbol = g:NERDTreeDirArrowExpandable
|
||||
endif
|
||||
|
||||
let l:symbol = (l:cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable )
|
||||
let l:symbol .= (g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ')
|
||||
let l:flags = l:cascade[-1].path.flagSet.renderToString()
|
||||
|
||||
let l:result = l:symbol . ' ' . l:flags . l:label
|
||||
return l:result
|
||||
return l:symbol . l:flags . l:label
|
||||
endfunction
|
||||
|
||||
" FUNCTION: TreeDirNode.findNode(path) {{{1
|
||||
@ -241,7 +236,7 @@ function! s:TreeDirNode.getChildIndex(path)
|
||||
let z = self.getChildCount()
|
||||
while a < z
|
||||
let mid = (a+z)/2
|
||||
let diff = a:path.compareTo(self.children[mid].path)
|
||||
let diff = nerdtree#compareNodePaths(a:path, self.children[mid].path)
|
||||
|
||||
if diff ==# -1
|
||||
let z = mid
|
||||
@ -283,8 +278,8 @@ function! s:TreeDirNode._glob(pattern, all)
|
||||
else
|
||||
let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',')
|
||||
|
||||
" On Windows, the drive letter may be removed by fnamemodify().
|
||||
if nerdtree#runningWindows() && l:pathSpec[0] ==# g:NERDTreePath.Slash()
|
||||
" On Windows, the drive letter may be removed by "fnamemodify()".
|
||||
if nerdtree#runningWindows() && l:pathSpec[0] == nerdtree#slash()
|
||||
let l:pathSpec = self.path.drive . l:pathSpec
|
||||
endif
|
||||
endif
|
||||
@ -382,11 +377,17 @@ endfunction
|
||||
" 1. If cascaded, we don't know which dir is bookmarked or is a symlink.
|
||||
" 2. If the parent is a symlink or is bookmarked, you end up with unparsable
|
||||
" text, and NERDTree cannot get the path of any child node.
|
||||
" Also, return false if this directory is the tree root, which should never be
|
||||
" part of a cascade.
|
||||
function! s:TreeDirNode.isCascadable()
|
||||
if g:NERDTreeCascadeSingleChildDir ==# 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
if self.isRoot()
|
||||
return 0
|
||||
endif
|
||||
|
||||
if self.path.isSymLink
|
||||
return 0
|
||||
endif
|
||||
@ -430,6 +431,7 @@ function! s:TreeDirNode._initChildren(silent)
|
||||
endtry
|
||||
endfor
|
||||
|
||||
let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder
|
||||
call self.sortChildren()
|
||||
|
||||
call nerdtree#echo('')
|
||||
@ -672,7 +674,7 @@ function! s:TreeDirNode.sortChildren()
|
||||
if count(g:NERDTreeSortOrder, '*') < 1
|
||||
call add(g:NERDTreeSortOrder, '*')
|
||||
endif
|
||||
let CompareFunc = function('nerdtree#compareNodesBySortKey')
|
||||
let CompareFunc = function('nerdtree#compareNodes')
|
||||
call sort(self.children, CompareFunc)
|
||||
let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder
|
||||
endfunction
|
||||
|
@ -321,13 +321,9 @@ function! s:TreeFileNode._renderToString(depth, drawText)
|
||||
if a:drawText ==# 1
|
||||
|
||||
let treeParts = repeat(' ', a:depth - 1)
|
||||
|
||||
if !self.path.isDirectory
|
||||
let treeParts = treeParts . ' '
|
||||
endif
|
||||
let treeParts .= (self.path.isDirectory || g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ')
|
||||
|
||||
let line = treeParts . self.displayString()
|
||||
|
||||
let output = output . line . "\n"
|
||||
endif
|
||||
|
||||
|
@ -99,6 +99,10 @@ function! s:UI._dumpHelp()
|
||||
let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n"
|
||||
let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n"
|
||||
let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n"
|
||||
let help .= '" '. g:NERDTreeMapOpenSplit .": open split\n"
|
||||
let help .= '" '. g:NERDTreeMapPreviewSplit .": preview split\n"
|
||||
let help .= '" '. g:NERDTreeMapOpenVSplit .": open vsplit\n"
|
||||
let help .= '" '. g:NERDTreeMapPreviewVSplit .": preview vsplit\n"
|
||||
let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n"
|
||||
let help .= '" '. g:NERDTreeMapDeleteBookmark .": delete bookmark\n"
|
||||
>>>>>>> 27ad0d07862847896f691309a544a206783c94d6
|
||||
@ -317,7 +321,11 @@ endfunction
|
||||
function! s:UI._indentLevelFor(line)
|
||||
" Replace multi-character DirArrows with a single space so the
|
||||
" indentation calculation doesn't get messed up.
|
||||
let l:line = substitute(substitute(a:line, '\V'.g:NERDTreeDirArrowExpandable, ' ', ''), '\V'.g:NERDTreeDirArrowCollapsible, ' ', '')
|
||||
if g:NERDTreeDirArrowExpandable ==# ''
|
||||
let l:line = ' '.a:line
|
||||
else
|
||||
let l:line = substitute(substitute(a:line, '\V'.g:NERDTreeDirArrowExpandable, ' ', ''), '\V'.g:NERDTreeDirArrowCollapsible, ' ', '')
|
||||
endif
|
||||
let leadChars = match(l:line, '\M\[^ ]')
|
||||
return leadChars / s:UI.IndentWid()
|
||||
endfunction
|
||||
@ -393,7 +401,7 @@ function! s:UI.saveScreenState()
|
||||
call g:NERDTree.CursorToTreeWin()
|
||||
let self._screenState['oldPos'] = getpos('.')
|
||||
let self._screenState['oldTopLine'] = line('w0')
|
||||
let self._screenState['oldWindowSize']= winwidth('')
|
||||
let self._screenState['oldWindowSize'] = winnr('$')==1 ? g:NERDTreeWinSize : winwidth('')
|
||||
call nerdtree#exec(win . 'wincmd w', 1)
|
||||
catch
|
||||
endtry
|
||||
@ -541,8 +549,7 @@ endfunction
|
||||
" zoom (maximize/minimize) the NERDTree window
|
||||
function! s:UI.toggleZoom()
|
||||
if exists('b:NERDTreeZoomed') && b:NERDTreeZoomed
|
||||
let size = exists('b:NERDTreeOldWindowSize') ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
|
||||
call nerdtree#exec('silent vertical resize '. size, 1)
|
||||
call nerdtree#exec('silent vertical resize '. g:NERDTreeWinSize, 1)
|
||||
let b:NERDTreeZoomed = 0
|
||||
else
|
||||
call nerdtree#exec('vertical resize '. get(g:, 'NERDTreeWinSizeMax', ''), 1)
|
||||
|
Reference in New Issue
Block a user