mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated plugins
This commit is contained in:
@ -280,14 +280,17 @@ endfunction
|
||||
" FUNCTION: Bookmark.str() {{{1
|
||||
" Get the string that should be rendered in the view for this bookmark
|
||||
function! s:Bookmark.str()
|
||||
let pathStrMaxLen = winwidth(g:NERDTree.GetWinNum()) - 4 - len(self.name)
|
||||
let pathStrMaxLen = winwidth(g:NERDTree.GetWinNum()) - 4 - strdisplaywidth(self.name)
|
||||
if &nu
|
||||
let pathStrMaxLen = pathStrMaxLen - &numberwidth
|
||||
endif
|
||||
|
||||
let pathStr = self.path.str({'format': 'UI'})
|
||||
if len(pathStr) > pathStrMaxLen
|
||||
let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen)
|
||||
if strdisplaywidth(pathStr) > pathStrMaxLen
|
||||
while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0
|
||||
let pathStr = substitute(pathStr, '^.', '', '')
|
||||
endwhile
|
||||
let pathStr = '<' . pathStr
|
||||
endif
|
||||
return '>' . self.name . ' ' . pathStr
|
||||
endfunction
|
||||
|
@ -178,24 +178,28 @@ function! s:Creator.createMirror()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:Creator._createTreeWin() {{{1
|
||||
" Inits the NERD tree window. ie. opens it, sizes it, sets all the local
|
||||
" options etc
|
||||
" Initialize the NERDTree window. Open the window, size it properly, set all
|
||||
" local options, etc.
|
||||
function! s:Creator._createTreeWin()
|
||||
"create the nerd tree window
|
||||
let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright "
|
||||
let splitSize = g:NERDTreeWinSize
|
||||
let l:splitLocation = g:NERDTreeWinPos ==# 'left' ? 'topleft ' : 'botright '
|
||||
let l:splitSize = g:NERDTreeWinSize
|
||||
|
||||
if !g:NERDTree.ExistsForTab()
|
||||
let t:NERDTreeBufName = self._nextBufferName()
|
||||
silent! exec splitLocation . 'vertical ' . splitSize . ' new'
|
||||
silent! exec "edit " . t:NERDTreeBufName
|
||||
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' new'
|
||||
silent! execute 'edit ' . t:NERDTreeBufName
|
||||
else
|
||||
silent! exec splitLocation . 'vertical ' . splitSize . ' split'
|
||||
silent! exec "buffer " . t:NERDTreeBufName
|
||||
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' split'
|
||||
silent! execute 'buffer ' . t:NERDTreeBufName
|
||||
endif
|
||||
|
||||
call self._setCommonBufOptions()
|
||||
|
||||
if has('patch-7.4.1925')
|
||||
clearjumps
|
||||
endif
|
||||
|
||||
setlocal winfixwidth
|
||||
call self._setCommonBufOptions()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:Creator._isBufHidden(nr) {{{1
|
||||
|
@ -2,28 +2,38 @@
|
||||
"============================================================
|
||||
let s:KeyMap = {}
|
||||
let g:NERDTreeKeyMap = s:KeyMap
|
||||
let s:keyMaps = {}
|
||||
|
||||
"FUNCTION: KeyMap.All() {{{1
|
||||
function! s:KeyMap.All()
|
||||
if !exists("s:keyMaps")
|
||||
let s:keyMaps = []
|
||||
let sortedKeyMaps = values(s:keyMaps)
|
||||
call sort(sortedKeyMaps, s:KeyMap.Compare, s:KeyMap)
|
||||
|
||||
return sortedKeyMaps
|
||||
endfunction
|
||||
|
||||
"FUNCTION: KeyMap.Compare(keyMap1, keyMap2) {{{1
|
||||
function! s:KeyMap.Compare(keyMap1, keyMap2)
|
||||
|
||||
if a:keyMap1.key >? a:keyMap2.key
|
||||
return 1
|
||||
endif
|
||||
return s:keyMaps
|
||||
|
||||
if a:keyMap1.key <? a:keyMap2.key
|
||||
return -1
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"FUNCTION: KeyMap.FindFor(key, scope) {{{1
|
||||
function! s:KeyMap.FindFor(key, scope)
|
||||
for i in s:KeyMap.All()
|
||||
if i.key ==# a:key && i.scope ==# a:scope
|
||||
return i
|
||||
endif
|
||||
endfor
|
||||
return {}
|
||||
return get(s:keyMaps, a:key . a:scope, {})
|
||||
endfunction
|
||||
|
||||
"FUNCTION: KeyMap.BindAll() {{{1
|
||||
function! s:KeyMap.BindAll()
|
||||
for i in s:KeyMap.All()
|
||||
for i in values(s:keyMaps)
|
||||
call i.bind()
|
||||
endfor
|
||||
endfunction
|
||||
@ -49,12 +59,7 @@ endfunction
|
||||
|
||||
"FUNCTION: KeyMap.Remove(key, scope) {{{1
|
||||
function! s:KeyMap.Remove(key, scope)
|
||||
let maps = s:KeyMap.All()
|
||||
for i in range(len(maps))
|
||||
if maps[i].key ==# a:key && maps[i].scope ==# a:scope
|
||||
return remove(maps, i)
|
||||
endif
|
||||
endfor
|
||||
return remove(s:keyMaps, a:key . a:scope)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: KeyMap.invoke() {{{1
|
||||
@ -152,8 +157,7 @@ endfunction
|
||||
|
||||
"FUNCTION: KeyMap.Add(keymap) {{{1
|
||||
function! s:KeyMap.Add(keymap)
|
||||
call s:KeyMap.Remove(a:keymap.key, a:keymap.scope)
|
||||
call add(s:KeyMap.All(), a:keymap)
|
||||
let s:keyMaps[a:keymap.key . a:keymap.scope] = a:keymap
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
@ -15,29 +15,35 @@ function! s:MenuController.New(menuItems)
|
||||
return newMenuController
|
||||
endfunction
|
||||
|
||||
"FUNCTION: MenuController.showMenu() {{{1
|
||||
"start the main loop of the menu and get the user to choose/execute a menu
|
||||
"item
|
||||
" FUNCTION: MenuController.showMenu() {{{1
|
||||
" Enter the main loop of the NERDTree menu, prompting the user to select
|
||||
" a menu item.
|
||||
function! s:MenuController.showMenu()
|
||||
call self._saveOptions()
|
||||
|
||||
try
|
||||
let self.selection = 0
|
||||
let l:done = 0
|
||||
|
||||
let done = 0
|
||||
while !done
|
||||
while !l:done
|
||||
redraw!
|
||||
call self._echoPrompt()
|
||||
let key = nr2char(getchar())
|
||||
let done = self._handleKeypress(key)
|
||||
|
||||
let l:key = nr2char(getchar())
|
||||
let l:done = self._handleKeypress(l:key)
|
||||
endwhile
|
||||
finally
|
||||
call self._restoreOptions()
|
||||
|
||||
" Redraw when "Ctrl-C" or "Esc" is received.
|
||||
if !l:done || self.selection == -1
|
||||
redraw!
|
||||
endif
|
||||
endtry
|
||||
|
||||
if self.selection != -1
|
||||
let m = self._current()
|
||||
call m.execute()
|
||||
let l:m = self._current()
|
||||
call l:m.execute()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -663,6 +663,8 @@ function! s:Path.rename(newPath)
|
||||
throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath
|
||||
endif
|
||||
|
||||
call s:Path.createParentDirectories(a:newPath)
|
||||
|
||||
let success = rename(self.str(), a:newPath)
|
||||
if success != 0
|
||||
throw "NERDTree.PathRenameError: Could not rename: '" . self.str() . "'" . 'to:' . a:newPath
|
||||
@ -719,8 +721,10 @@ function! s:Path.str(...)
|
||||
|
||||
if has_key(options, 'truncateTo')
|
||||
let limit = options['truncateTo']
|
||||
if len(toReturn) > limit-1
|
||||
let toReturn = toReturn[(len(toReturn)-limit+1):]
|
||||
if strdisplaywidth(toReturn) > limit-1
|
||||
while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0
|
||||
let toReturn = substitute(toReturn, '^.', '', '')
|
||||
endwhile
|
||||
if len(split(toReturn, '/')) > 1
|
||||
let toReturn = '</' . join(split(toReturn, '/')[1:], '/') . '/'
|
||||
else
|
||||
|
@ -390,7 +390,7 @@ endfunction
|
||||
|
||||
" FUNCTION: s:UI.render() {{{1
|
||||
function! s:UI.render()
|
||||
setlocal modifiable
|
||||
setlocal noreadonly modifiable
|
||||
|
||||
" remember the top line of the buffer and the current line so we can
|
||||
" restore the view exactly how it was
|
||||
@ -438,7 +438,7 @@ function! s:UI.render()
|
||||
call cursor(curLine, curCol)
|
||||
let &scrolloff = old_scrolloff
|
||||
|
||||
setlocal nomodifiable
|
||||
setlocal readonly nomodifiable
|
||||
endfunction
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user