mirror of
https://github.com/amix/vimrc
synced 2025-06-17 19:35:00 +08:00
Updated plugins
This commit is contained in:
@ -30,6 +30,16 @@ endfunction
|
||||
" SECTION: General Functions {{{1
|
||||
"============================================================
|
||||
|
||||
" FUNCTION: nerdtree#closeTreeOnOpen() {{{2
|
||||
function! nerdtree#closeTreeOnOpen() abort
|
||||
return g:NERDTreeQuitOnOpen == 1 || g:NERDTreeQuitOnOpen == 3
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#closeBookmarksOnOpen() {{{2
|
||||
function! nerdtree#closeBookmarksOnOpen() abort
|
||||
return g:NERDTreeQuitOnOpen == 2 || g:NERDTreeQuitOnOpen == 3
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#slash() {{{2
|
||||
" Return the path separator used by the underlying file system. Special
|
||||
" consideration is taken for the use of the 'shellslash' option on Windows
|
||||
@ -46,28 +56,6 @@ function! nerdtree#slash() abort
|
||||
return '/'
|
||||
endfunction
|
||||
|
||||
"FUNCTION: nerdtree#and(x,y) {{{2
|
||||
" Implements and() function for Vim <= 7.4
|
||||
function! nerdtree#and(x,y) abort
|
||||
if exists('*and')
|
||||
return and(a:x, a:y)
|
||||
else
|
||||
let l:x = a:x
|
||||
let l:y = a:y
|
||||
let l:n = 0
|
||||
let l:result = 0
|
||||
while l:x > 0 && l:y > 0
|
||||
if (l:x % 2) && (l:y % 2)
|
||||
let l:result += float2nr(pow(2, l:n))
|
||||
endif
|
||||
let l:x = float2nr(l:x / 2)
|
||||
let l:y = float2nr(l:y / 2)
|
||||
let l:n += 1
|
||||
endwhile
|
||||
return l:result
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
|
||||
"inits a window tree in the current buffer if appropriate
|
||||
function! nerdtree#checkForBrowse(dir) abort
|
||||
|
@ -108,10 +108,17 @@ function! s:customOpenBookmark(node) abort
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:initCustomOpenArgs() {{{1
|
||||
" Make sure NERDTreeCustomOpenArgs has needed keys
|
||||
function! s:initCustomOpenArgs() abort
|
||||
let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {})
|
||||
return extend(g:NERDTreeCustomOpenArgs, {'file':{'reuse': 'all', 'where': 'p'}, 'dir':{}}, 'keep')
|
||||
let l:defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p', 'keepopen':!nerdtree#closeTreeOnOpen()}, 'dir': {}}
|
||||
try
|
||||
let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {})
|
||||
call extend(g:NERDTreeCustomOpenArgs, l:defaultOpenArgs, 'keep')
|
||||
catch /^Vim(\a\+):E712:/
|
||||
call nerdtree#echoWarning('g:NERDTreeCustomOpenArgs is not set properly. Using default value.')
|
||||
let g:NERDTreeCustomOpenArgs = l:defaultOpenArgs
|
||||
finally
|
||||
return g:NERDTreeCustomOpenArgs
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:activateAll() {{{1
|
||||
@ -137,13 +144,13 @@ endfunction
|
||||
"FUNCTION: s:activateFileNode() {{{1
|
||||
"handle the user activating a tree node
|
||||
function! s:activateFileNode(node) abort
|
||||
call a:node.activate({'reuse': 'all', 'where': 'p'})
|
||||
call a:node.activate({'reuse': 'all', 'where': 'p', 'keepopen': !nerdtree#closeTreeOnOpen()})
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:activateBookmark(bookmark) {{{1
|
||||
"handle the user activating a bookmark
|
||||
function! s:activateBookmark(bm) abort
|
||||
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {})
|
||||
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p', 'keepopen': !nerdtree#closeTreeOnOpen()} : {})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1
|
||||
@ -366,7 +373,7 @@ function! s:handleLeftClick() abort
|
||||
if currentNode.path.isDirectory
|
||||
call currentNode.activate()
|
||||
else
|
||||
call currentNode.activate({'reuse': 'all', 'where': 'p'})
|
||||
call currentNode.activate({'reuse': 'all', 'where': 'p', 'keepopen':!nerdtree#closeTreeOnOpen()})
|
||||
endif
|
||||
return
|
||||
endif
|
||||
@ -500,31 +507,32 @@ function! nerdtree#ui_glue#openBookmark(name) abort
|
||||
endtry
|
||||
if l:bookmark.path.isDirectory
|
||||
call l:bookmark.open(b:NERDTree)
|
||||
else
|
||||
call l:bookmark.open(b:NERDTree, {'where': 'p'})
|
||||
return
|
||||
endif
|
||||
|
||||
call l:bookmark.open(b:NERDTree, s:initCustomOpenArgs().file)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:openHSplit(target) {{{1
|
||||
function! s:openHSplit(target) abort
|
||||
call a:target.activate({'where': 'h'})
|
||||
call a:target.activate({'where': 'h', 'keepopen': !nerdtree#closeTreeOnOpen()})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:openVSplit(target) {{{1
|
||||
function! s:openVSplit(target) abort
|
||||
call a:target.activate({'where': 'v'})
|
||||
call a:target.activate({'where': 'v', 'keepopen': !nerdtree#closeTreeOnOpen()})
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:openHSplitBookmark(bookmark) {{{1
|
||||
"handle the user activating a bookmark
|
||||
function! s:openHSplitBookmark(bm) abort
|
||||
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'h'} : {})
|
||||
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'h', 'keepopen': !nerdtree#closeTreeOnOpen()} : {})
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:openVSplitBookmark(bookmark) {{{1
|
||||
"handle the user activating a bookmark
|
||||
function! s:openVSplitBookmark(bm) abort
|
||||
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'v'} : {})
|
||||
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'v', 'keepopen': !nerdtree#closeTreeOnOpen()} : {})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:previewHSplitBookmark(bookmark) {{{1
|
||||
@ -544,13 +552,13 @@ endfunction
|
||||
|
||||
" FUNCTION: s:openInNewTab(target) {{{1
|
||||
function! s:openInNewTab(target) abort
|
||||
let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't'})
|
||||
let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'keepopen': !nerdtree#closeTreeOnOpen()})
|
||||
call l:opener.open(a:target)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:openInNewTabSilent(target) {{{1
|
||||
function! s:openInNewTabSilent(target) abort
|
||||
let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'stay': 1})
|
||||
let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'keepopen': !nerdtree#closeTreeOnOpen(), 'stay': 1})
|
||||
call l:opener.open(a:target)
|
||||
endfunction
|
||||
|
||||
@ -564,7 +572,11 @@ endfunction
|
||||
|
||||
" FUNCTION: s:previewBookmark(bookmark) {{{1
|
||||
function! s:previewBookmark(bookmark) abort
|
||||
call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'h', 'keepopen': 1} : {})
|
||||
if a:bookmark.path.isDirectory
|
||||
execute 'NERDTreeFind '.a:bookmark.path.str()
|
||||
else
|
||||
call a:bookmark.activate(b:NERDTree, {'stay': 1, 'where': 'p', 'keepopen': 1})
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:previewNodeCurrent(node) {{{1
|
||||
@ -589,7 +601,7 @@ function! nerdtree#ui_glue#revealBookmark(name) abort
|
||||
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree)
|
||||
call targetNode.putCursorHere(0, 1)
|
||||
catch /^NERDTree.BookmarkNotFoundError/
|
||||
call nerdtree#echo('Bookmark isnt cached under the current root')
|
||||
call nerdtree#echo('Bookmark isn''t cached under the current root')
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
|
Reference in New Issue
Block a user