mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated plugins
This commit is contained in:
@ -343,7 +343,12 @@ function! s:Bookmark.Write()
|
||||
for j in s:Bookmark.InvalidBookmarks()
|
||||
call add(bookmarkStrings, j)
|
||||
endfor
|
||||
call writefile(bookmarkStrings, g:NERDTreeBookmarksFile)
|
||||
|
||||
try
|
||||
call writefile(bookmarkStrings, g:NERDTreeBookmarksFile)
|
||||
catch
|
||||
call nerdtree#echoError("Failed to write bookmarks file. Make sure g:NERDTreeBookmarksFile points to a valid location.")
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
@ -284,16 +284,21 @@ endfunction
|
||||
|
||||
" FUNCTION: s:Creator._setCommonBufOptions() {{{1
|
||||
function! s:Creator._setCommonBufOptions()
|
||||
"throwaway buffer options
|
||||
setlocal noswapfile
|
||||
setlocal buftype=nofile
|
||||
|
||||
" Options for a non-file/control buffer.
|
||||
setlocal bufhidden=hide
|
||||
setlocal nowrap
|
||||
setlocal buftype=nofile
|
||||
setlocal noswapfile
|
||||
|
||||
" Options for controlling buffer/window appearance.
|
||||
setlocal foldcolumn=0
|
||||
setlocal foldmethod=manual
|
||||
setlocal nofoldenable
|
||||
setlocal nobuflisted
|
||||
setlocal nofoldenable
|
||||
setlocal nolist
|
||||
setlocal nospell
|
||||
setlocal nowrap
|
||||
|
||||
if g:NERDTreeShowLineNumbers
|
||||
setlocal nu
|
||||
else
|
||||
@ -311,6 +316,7 @@ function! s:Creator._setCommonBufOptions()
|
||||
|
||||
call self._setupStatusline()
|
||||
call self._bindMappings()
|
||||
|
||||
setlocal filetype=nerdtree
|
||||
endfunction
|
||||
|
||||
|
@ -243,6 +243,9 @@ endfunction
|
||||
|
||||
" FUNCTION: Opener._openFile() {{{1
|
||||
function! s:Opener._openFile()
|
||||
if !self._stay && !g:NERDTreeQuitOnOpen && exists("b:NERDTreeZoomed") && b:NERDTreeZoomed
|
||||
call b:NERDTree.ui.toggleZoom()
|
||||
endif
|
||||
|
||||
if self._reuseWindow()
|
||||
return
|
||||
|
@ -153,6 +153,32 @@ function! s:TreeDirNode.getCascade()
|
||||
return [self] + visChild.getCascade()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: TreeDirNode.getCascadeRoot() {{{1
|
||||
" Return the first directory node in the cascade in which this directory node
|
||||
" is rendered.
|
||||
function! s:TreeDirNode.getCascadeRoot()
|
||||
|
||||
" Don't search above the current NERDTree root node.
|
||||
if self.isRoot()
|
||||
return self
|
||||
endif
|
||||
|
||||
let l:cascadeRoot = self
|
||||
let l:parent = self.parent
|
||||
|
||||
while !empty(l:parent) && !l:parent.isRoot()
|
||||
|
||||
if index(l:parent.getCascade(), self) == -1
|
||||
break
|
||||
endif
|
||||
|
||||
let l:cascadeRoot = l:parent
|
||||
let l:parent = l:parent.parent
|
||||
endwhile
|
||||
|
||||
return l:cascadeRoot
|
||||
endfunction
|
||||
|
||||
" FUNCTION: TreeDirNode.getChildCount() {{{1
|
||||
" Returns the number of children this node has
|
||||
function! s:TreeDirNode.getChildCount()
|
||||
|
@ -116,68 +116,40 @@ function! s:TreeFileNode.findNode(path)
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
" FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{1
|
||||
"
|
||||
" Finds the next sibling for this node in the indicated direction. This sibling
|
||||
" must be a directory and may/may not have children as specified.
|
||||
"
|
||||
" Args:
|
||||
" direction: 0 if you want to find the previous sibling, 1 for the next sibling
|
||||
"
|
||||
" Return:
|
||||
" a treenode object or {} if no appropriate sibling could be found
|
||||
function! s:TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction)
|
||||
" if we have no parent then we can have no siblings
|
||||
if self.parent != {}
|
||||
let nextSibling = self.findSibling(a:direction)
|
||||
|
||||
while nextSibling != {}
|
||||
if nextSibling.path.isDirectory && nextSibling.hasVisibleChildren() && nextSibling.isOpen
|
||||
return nextSibling
|
||||
endif
|
||||
let nextSibling = nextSibling.findSibling(a:direction)
|
||||
endwhile
|
||||
endif
|
||||
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
" FUNCTION: TreeFileNode.findSibling(direction) {{{1
|
||||
"
|
||||
" Finds the next sibling for this node in the indicated direction
|
||||
" Find the next or previous sibling of this node.
|
||||
"
|
||||
" Args:
|
||||
" direction: 0 if you want to find the previous sibling, 1 for the next sibling
|
||||
" direction: 0 for previous, 1 for next
|
||||
"
|
||||
" Return:
|
||||
" a treenode object or {} if no sibling could be found
|
||||
" The next/previous TreeFileNode object or an empty dictionary if not found.
|
||||
function! s:TreeFileNode.findSibling(direction)
|
||||
" if we have no parent then we can have no siblings
|
||||
if self.parent != {}
|
||||
|
||||
" get the index of this node in its parents children
|
||||
let siblingIndx = self.parent.getChildIndex(self.path)
|
||||
|
||||
if siblingIndx != -1
|
||||
" move a long to the next potential sibling node
|
||||
let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1
|
||||
|
||||
" keep moving along to the next sibling till we find one that is valid
|
||||
let numSiblings = self.parent.getChildCount()
|
||||
while siblingIndx >= 0 && siblingIndx < numSiblings
|
||||
|
||||
" if the next node is not an ignored node (i.e. wont show up in the
|
||||
" view) then return it
|
||||
if self.parent.children[siblingIndx].path.ignore(self.getNerdtree()) ==# 0
|
||||
return self.parent.children[siblingIndx]
|
||||
endif
|
||||
|
||||
" go to next node
|
||||
let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1
|
||||
endwhile
|
||||
endif
|
||||
" There can be no siblings if there is no parent.
|
||||
if empty(self.parent)
|
||||
return {}
|
||||
endif
|
||||
|
||||
let l:nodeIndex = self.parent.getChildIndex(self.path)
|
||||
|
||||
if l:nodeIndex == -1
|
||||
return {}
|
||||
endif
|
||||
|
||||
" Get the next index to begin the search.
|
||||
let l:nodeIndex += a:direction ? 1 : -1
|
||||
|
||||
while 0 <= l:nodeIndex && l:nodeIndex < self.parent.getChildCount()
|
||||
|
||||
" Return the next node if it is not ignored.
|
||||
if !self.parent.children[l:nodeIndex].path.ignore(self.getNerdtree())
|
||||
return self.parent.children[l:nodeIndex]
|
||||
endif
|
||||
|
||||
let l:nodeIndex += a:direction ? 1 : -1
|
||||
endwhile
|
||||
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
|
@ -194,51 +194,52 @@ function! s:UI.getPath(ln)
|
||||
return toReturn
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI.getLineNum(file_node){{{1
|
||||
" returns the line number this node is rendered on, or -1 if it isnt rendered
|
||||
function! s:UI.getLineNum(file_node)
|
||||
" if the node is the root then return the root line no.
|
||||
if a:file_node.isRoot()
|
||||
" FUNCTION: s:UI.getLineNum(node) {{{1
|
||||
" Return the line number where the given node is rendered. Return -1 if the
|
||||
" given node is not visible.
|
||||
function! s:UI.getLineNum(node)
|
||||
|
||||
if a:node.isRoot()
|
||||
return self.getRootLineNum()
|
||||
endif
|
||||
|
||||
let totalLines = line("$")
|
||||
let l:pathComponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/\s*$', '', '')]
|
||||
let l:currentPathComponent = 1
|
||||
|
||||
" the path components we have matched so far
|
||||
let pathcomponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/ *$', '', '')]
|
||||
" the index of the component we are searching for
|
||||
let curPathComponent = 1
|
||||
let l:fullPath = a:node.path.str({'format': 'UI'})
|
||||
|
||||
let fullpath = a:file_node.path.str({'format': 'UI'})
|
||||
for l:lineNumber in range(self.getRootLineNum() + 1, line('$'))
|
||||
let l:currentLine = getline(l:lineNumber)
|
||||
let l:indentLevel = self._indentLevelFor(l:currentLine)
|
||||
|
||||
let lnum = self.getRootLineNum()
|
||||
while lnum > 0
|
||||
let lnum = lnum + 1
|
||||
" have we reached the bottom of the tree?
|
||||
if lnum ==# totalLines+1
|
||||
return -1
|
||||
if l:indentLevel != l:currentPathComponent
|
||||
continue
|
||||
endif
|
||||
|
||||
let curLine = getline(lnum)
|
||||
let l:currentLine = self._stripMarkup(l:currentLine)
|
||||
let l:currentPath = join(l:pathComponents, '/') . '/' . l:currentLine
|
||||
|
||||
let indent = self._indentLevelFor(curLine)
|
||||
if indent ==# curPathComponent
|
||||
let curLine = self._stripMarkup(curLine)
|
||||
|
||||
let curPath = join(pathcomponents, '/') . '/' . curLine
|
||||
if stridx(fullpath, curPath, 0) ==# 0
|
||||
if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/'
|
||||
let curLine = substitute(curLine, '/ *$', '', '')
|
||||
call add(pathcomponents, curLine)
|
||||
let curPathComponent = curPathComponent + 1
|
||||
|
||||
if fullpath ==# curPath
|
||||
return lnum
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
" Directories: If the current path "starts with" the full path, then
|
||||
" either the paths are equal or the line is a cascade containing the
|
||||
" full path.
|
||||
if l:fullPath[-1:] == '/' && stridx(l:currentPath, l:fullPath) == 0
|
||||
return l:lineNumber
|
||||
endif
|
||||
endwhile
|
||||
|
||||
" Files: The paths must exactly match.
|
||||
if l:fullPath ==# l:currentPath
|
||||
return l:lineNumber
|
||||
endif
|
||||
|
||||
" Otherwise: If the full path starts with the current path and the
|
||||
" current path is a directory, we add a new path component.
|
||||
if stridx(l:fullPath, l:currentPath) == 0 && l:currentPath[-1:] == '/'
|
||||
let l:currentLine = substitute(l:currentLine, '/\s*$', '', '')
|
||||
call add(l:pathComponents, l:currentLine)
|
||||
let l:currentPathComponent += 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
|
Reference in New Issue
Block a user