mirror of
https://github.com/amix/vimrc
synced 2025-07-13 06:35:01 +08:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2008-11-25.
|
||||
" @Last Change: 2014-01-23.
|
||||
" @Revision: 0.0.108
|
||||
" @Last Change: 2014-06-02.
|
||||
" @Revision: 0.0.109
|
||||
|
||||
let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2
|
||||
let s:prototype.highlight = g:tlib#input#higroup
|
||||
@ -57,28 +57,6 @@ function! s:prototype.AssessName(world, name) dict "{{{3
|
||||
elseif a:name =~ '\A'. flt .'\|'. flt .'\A'
|
||||
let xa += 1
|
||||
endif
|
||||
|
||||
" if a:name =~ '\^'. flt .'\|'. flt .'\$'
|
||||
" let xa += 4
|
||||
" elseif a:name =~ '\<'. flt .'\|'. flt .'\>'
|
||||
" let xa += 3
|
||||
" " elseif a:name =~ flt .'\>'
|
||||
" " let xa += 2
|
||||
" elseif a:name =~ '\A'. flt .'\|'. flt .'\A'
|
||||
" let xa += 1
|
||||
" endif
|
||||
" if flt[0] =~# '\u' && matchstr(a:name, '\V\.\ze'. flt) =~# '\U'
|
||||
" let xa += 1
|
||||
" endif
|
||||
" if flt[0] =~# '\U' && matchstr(a:name, '\V\.\ze'. flt) =~# '\u'
|
||||
" let xa += 1
|
||||
" endif
|
||||
" if flt[-1] =~# '\u' && matchstr(a:name, '\V'. flt .'\zs\.') =~# '\U'
|
||||
" let xa += 1
|
||||
" endif
|
||||
" if flt[-1] =~# '\U' && matchstr(a:name, '\V'. flt .'\zs\.') =~# '\u'
|
||||
" let xa += 1
|
||||
" endif
|
||||
endfor
|
||||
" TLogVAR a:name, xa
|
||||
return xa
|
||||
|
@ -1,7 +1,7 @@
|
||||
" @Author: Tom Link (micathom AT gmail com?subject=[vim])
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Revision: 1389
|
||||
" @Revision: 1393
|
||||
|
||||
" :filedoc:
|
||||
" A prototype used by |tlib#input#List|.
|
||||
@ -500,6 +500,7 @@ function! s:prototype.SetPrefIdx() dict "{{{3
|
||||
let pref_idx = -1
|
||||
let pref_weight = -1
|
||||
" TLogVAR self.filter_pos, self.filter_neg
|
||||
" let t0 = localtime() " DBG
|
||||
for idx in range(1, self.llen)
|
||||
let item = self.GetItem(idx)
|
||||
let weight = self.matcher.AssessName(self, item)
|
||||
@ -509,6 +510,7 @@ function! s:prototype.SetPrefIdx() dict "{{{3
|
||||
let pref_weight = weight
|
||||
endif
|
||||
endfor
|
||||
" TLogVAR localtime() - t0
|
||||
" TLogVAR pref_idx
|
||||
" TLogDBG self.GetItem(pref_idx)
|
||||
if pref_idx == -1
|
||||
@ -985,7 +987,7 @@ function! s:prototype.DisplayHelp() dict "{{{3
|
||||
endif
|
||||
if stridx(self.type, 'm') != -1
|
||||
call self.PushHelp('<S-Up/Down>', '(Un)Select items')
|
||||
call self.PushHelp('#, <C-Space>', '(Un)Select the current item')
|
||||
call self.PushHelp('#', '(Un)Select the current item')
|
||||
call self.PushHelp('<C|M-a>', '(Un)Select all items')
|
||||
call self.PushHelp('<F9>', '(Un)Restrict view to selection')
|
||||
" \ '<c-\> ... Show only selected',
|
||||
|
@ -1,15 +1,8 @@
|
||||
" arg.vim
|
||||
" @Author: Tom Link (micathom AT gmail com?subject=[vim])
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-30.
|
||||
" @Last Change: 2009-02-15.
|
||||
" @Revision: 0.0.50
|
||||
|
||||
if &cp || exists("loaded_tlib_arg_autoload")
|
||||
finish
|
||||
endif
|
||||
let loaded_tlib_arg_autoload = 1
|
||||
" @Last Change: 2014-07-01.
|
||||
" @Revision: 63
|
||||
|
||||
|
||||
" :def: function! tlib#arg#Get(n, var, ?default="", ?test='')
|
||||
@ -50,32 +43,40 @@ function! tlib#arg#Key(list, ...) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
" :def: function! tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0)
|
||||
" :def: function! tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0, ?sep=':')
|
||||
function! tlib#arg#StringAsKeyArgs(string, ...) "{{{1
|
||||
TVarArg ['keys', {}], ['evaluate', 0]
|
||||
TVarArg ['keys', {}], ['evaluate', 0], ['sep', ':']
|
||||
let keyargs = {}
|
||||
let args = split(a:string, '\\\@<! ')
|
||||
let arglist = map(args, 'matchlist(v:val, ''^\(\w\+\):\(.*\)$'')')
|
||||
let arglist = map(args, 'matchlist(v:val, ''^\%(\(\w\+\)'. sep .'\(.*\)\|\(.*\)\)$'')')
|
||||
" TLogVAR a:string, args, arglist
|
||||
let pos = 0
|
||||
for matchlist in arglist
|
||||
if len(matchlist) < 3
|
||||
throw 'Malformed key arguments: '. string(matchlist) .' in '. a:string
|
||||
endif
|
||||
let [match, key, val; rest] = matchlist
|
||||
if empty(keys) || has_key(keys, key)
|
||||
let val = substitute(val, '\\\\', '\\', 'g')
|
||||
if evaluate
|
||||
let val = eval(val)
|
||||
endif
|
||||
let keyargs[key] = val
|
||||
if !empty(matchlist[3])
|
||||
let keyargs[pos] = matchlist[3]
|
||||
let pos += 1
|
||||
else
|
||||
echom 'Unknown key: '. key .'='. val
|
||||
let [match, key, val; rest] = matchlist
|
||||
if empty(keys) || has_key(keys, key)
|
||||
let val = substitute(val, '\\\\', '\\', 'g')
|
||||
if evaluate
|
||||
let val = eval(val)
|
||||
endif
|
||||
let keyargs[key] = val
|
||||
else
|
||||
echom 'Unknown key: '. key .'='. val
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
return keyargs
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#arg#StringAsKeyArgsEqual(string) "{{{1
|
||||
return tlib#arg#StringAsKeyArgs(a:string, [], 0, '=')
|
||||
endf
|
||||
|
||||
|
||||
|
||||
""" Command line {{{1
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-30.
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.1.230
|
||||
" @Revision: 0.1.243
|
||||
|
||||
|
||||
" The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'.
|
||||
@ -88,7 +88,11 @@ function! tlib#cache#Filename(type, ...) "{{{3
|
||||
" TLogVAR file, dir, mkdir
|
||||
let cache_file = tlib#file#Join([dir, file])
|
||||
if len(cache_file) > g:tlib#cache#max_filename
|
||||
let shortfilename = pathshorten(file) .'_'. tlib#hash#Adler32(file)
|
||||
if v:version >= 704
|
||||
let shortfilename = pathshorten(file) .'_'. sha256(file)
|
||||
else
|
||||
let shortfilename = pathshorten(file) .'_'. tlib#hash#Adler32(file)
|
||||
endif
|
||||
let cache_file = tlib#cache#Filename(a:type, shortfilename, mkdir, dir0)
|
||||
else
|
||||
if mkdir && !isdirectory(dir)
|
||||
@ -108,9 +112,32 @@ function! tlib#cache#Filename(type, ...) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
let s:timestamps = {}
|
||||
|
||||
|
||||
function! s:SetTimestamp(cfile, type) "{{{3
|
||||
if !has_key(s:timestamps, a:cfile)
|
||||
let s:timestamps[a:cfile] = {}
|
||||
endif
|
||||
let s:timestamps[a:cfile].atime = getftime(a:cfile)
|
||||
let s:timestamps[a:cfile][a:type] = s:timestamps[a:cfile].atime
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#cache#Save(cfile, dictionary) "{{{3
|
||||
" TLogVAR a:cfile, a:dictionary
|
||||
call tlib#persistent#Save(a:cfile, a:dictionary)
|
||||
if !empty(a:cfile)
|
||||
" TLogVAR a:dictionary
|
||||
call writefile([string(a:dictionary)], a:cfile, 'b')
|
||||
call s:SetTimestamp(a:cfile, 'write')
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#cache#MTime(cfile) "{{{3
|
||||
let mtime = {'mtime': getftime(a:cfile)}
|
||||
let mtime = extend(mtime, get(s:timestamps, a:cfile, {}))
|
||||
return mtime
|
||||
endf
|
||||
|
||||
|
||||
@ -118,6 +145,7 @@ function! tlib#cache#Get(cfile, ...) "{{{3
|
||||
call tlib#cache#MaybePurge()
|
||||
if !empty(a:cfile) && filereadable(a:cfile)
|
||||
let val = readfile(a:cfile, 'b')
|
||||
call s:SetTimestamp(a:cfile, 'read')
|
||||
return eval(join(val, "\n"))
|
||||
else
|
||||
let default = a:0 >= 1 ? a:1 : {}
|
||||
@ -130,14 +158,9 @@ endf
|
||||
" or does not exist, create it calling a generator function.
|
||||
function! tlib#cache#Value(cfile, generator, ftime, ...) "{{{3
|
||||
if !filereadable(a:cfile) || (a:ftime != 0 && getftime(a:cfile) < a:ftime)
|
||||
if empty(a:generator) && a:0 >= 1
|
||||
" TLogVAR a:1
|
||||
let val = a:1
|
||||
else
|
||||
let args = a:0 >= 1 ? a:1 : []
|
||||
" TLogVAR a:generator, args
|
||||
let val = call(a:generator, args)
|
||||
endif
|
||||
let args = a:0 >= 1 ? a:1 : []
|
||||
" TLogVAR a:generator, args
|
||||
let val = call(a:generator, args)
|
||||
" TLogVAR val
|
||||
let cval = {'val': val}
|
||||
" TLogVAR cval
|
||||
|
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-30.
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.0.37
|
||||
" @Last Change: 2014-07-07.
|
||||
" @Revision: 0.0.38
|
||||
|
||||
if &cp || exists("loaded_tlib_dir_autoload")
|
||||
finish
|
||||
@ -21,10 +21,11 @@ let s:dir_stack = []
|
||||
" tlib#dir#CanonicName('foo/bar')
|
||||
" => 'foo/bar/'
|
||||
function! tlib#dir#CanonicName(dirname) "{{{3
|
||||
if a:dirname !~ '[/\\]$'
|
||||
return a:dirname . g:tlib#dir#sep
|
||||
let dirname = tlib#file#Canonic(a:dirname)
|
||||
if dirname !~ '[/\\]$'
|
||||
return dirname . g:tlib#dir#sep
|
||||
endif
|
||||
return a:dirname
|
||||
return dirname
|
||||
endf
|
||||
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-30.
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.0.142
|
||||
" @Last Change: 2014-07-07.
|
||||
" @Revision: 0.0.150
|
||||
|
||||
if &cp || exists("loaded_tlib_file_autoload")
|
||||
finish
|
||||
@ -103,6 +103,25 @@ function! tlib#file#Absolute(filename, ...) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#file#Canonic(filename, ...) "{{{3
|
||||
TVarArg ['mode', '']
|
||||
if a:filename =~ '^\\\\'
|
||||
let mode = 'windows'
|
||||
elseif a:filename =~ '^\(file\|ftp\|http\)s\?:'
|
||||
let mode = 'url'
|
||||
elseif (empty(mode) && g:tlib#sys#windows)
|
||||
let mode = 'windows'
|
||||
endif
|
||||
let filename = a:filename
|
||||
if mode == 'windows'
|
||||
let filename = substitute(filename, '/', '\\', 'g')
|
||||
else
|
||||
let filename = substitute(filename, '\\', '/', 'g')
|
||||
endif
|
||||
return filename
|
||||
endf
|
||||
|
||||
|
||||
function! s:SetScrollBind(world) "{{{3
|
||||
let sb = get(a:world, 'scrollbind', &scrollbind)
|
||||
if sb != &scrollbind
|
||||
|
@ -1,7 +1,7 @@
|
||||
" @Author: Tom Link (micathom AT gmail com?subject=[vim])
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Revision: 1315
|
||||
" @Revision: 1317
|
||||
|
||||
|
||||
" :filedoc:
|
||||
@ -325,6 +325,8 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
" TLogVAR world.state, world.sticky, world.initial_index
|
||||
" let statusline = &l:statusline
|
||||
" let laststatus = &laststatus
|
||||
let showmode = &showmode
|
||||
set noshowmode
|
||||
let lastsearch = @/
|
||||
let scrolloff = &l:scrolloff
|
||||
let &l:scrolloff = 0
|
||||
@ -779,6 +781,9 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
" TLogVAR statusline
|
||||
" let &l:statusline = statusline
|
||||
" let &laststatus = laststatus
|
||||
if &showmode != showmode
|
||||
let &showmode = showmode
|
||||
endif
|
||||
silent! let @/ = lastsearch
|
||||
let &l:scrolloff = scrolloff
|
||||
if s:PopupmenuExists() == 1
|
||||
|
@ -4,7 +4,7 @@
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-30.
|
||||
" @Last Change: 2011-03-18.
|
||||
" @Revision: 36
|
||||
" @Revision: 57
|
||||
|
||||
|
||||
""" List related functions {{{1
|
||||
@ -140,25 +140,41 @@ endf
|
||||
|
||||
|
||||
function! tlib#list#Uniq(list, ...) "{{{3
|
||||
TVarArg ['get_value', '']
|
||||
let s:uniq_values = {}
|
||||
TVarArg ['get_value', ''], ['remove_empty', 0]
|
||||
if remove_empty
|
||||
call filter(a:list, 'type(v:val) == 0 || !empty(v:val)')
|
||||
endif
|
||||
" CREDITS: Based on syntastic#util#unique(list) by scrooloose
|
||||
let seen = {}
|
||||
let uniques = []
|
||||
if empty(get_value)
|
||||
call filter(a:list, 's:UniqValue(v:val)')
|
||||
for e in a:list
|
||||
if !has_key(seen, e)
|
||||
let seen[e] = 1
|
||||
call add(uniques, e)
|
||||
endif
|
||||
endfor
|
||||
else
|
||||
call filter(a:list, 's:UniqValue(eval(printf(get_value, string(v:val))))')
|
||||
for e in a:list
|
||||
let v = eval(printf(get_value, string(e)))
|
||||
if !has_key(seen, v)
|
||||
let seen[v] = 1
|
||||
call add(uniques, e)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
unlet s:uniq_values
|
||||
return a:list
|
||||
return uniques
|
||||
endf
|
||||
|
||||
|
||||
function! s:UniqValue(value) "{{{3
|
||||
if get(s:uniq_values, a:value, 0)
|
||||
return 0
|
||||
else
|
||||
let s:uniq_values[a:value] = 1
|
||||
return 1
|
||||
endif
|
||||
function! tlib#list#ToDictionary(list, default, ...) "{{{3
|
||||
TVarArg ['generator', '']
|
||||
let dict = {}
|
||||
for item in a:list
|
||||
if !empty(item)
|
||||
let dict[item] = empty(generator) ? a:default : call(generator, [item, a:default])
|
||||
endif
|
||||
endfor
|
||||
return dict
|
||||
endf
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2012-05-11.
|
||||
" @Last Change: 2012-05-11.
|
||||
" @Revision: 9
|
||||
" @Revision: 12
|
||||
|
||||
" The directory for persistent data files. If empty, use
|
||||
" |tlib#dir#MyRuntime|.'/share'.
|
||||
@ -33,14 +33,15 @@ function! tlib#persistent#Get(...) "{{{3
|
||||
return call('tlib#cache#Get', a:000)
|
||||
endf
|
||||
|
||||
function! tlib#persistent#MTime(cfile) "{{{3
|
||||
return tlib#cache#MTime(a:cfile)
|
||||
endf
|
||||
|
||||
function! tlib#persistent#Value(...) "{{{3
|
||||
return call('tlib#cache#Value', a:000)
|
||||
endf
|
||||
|
||||
function! tlib#persistent#Save(cfile, dictionary) "{{{3
|
||||
if !empty(a:cfile)
|
||||
" TLogVAR a:dictionary
|
||||
call writefile([string(a:dictionary)], a:cfile, 'b')
|
||||
endif
|
||||
call tlib#cache#Save(a:cfile, a:dictionary)
|
||||
endf
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-30.
|
||||
" @Last Change: 2009-02-15.
|
||||
" @Revision: 0.0.110
|
||||
" @Revision: 0.0.115
|
||||
|
||||
if &cp || exists("loaded_tlib_string_autoload")
|
||||
finish
|
||||
@ -23,8 +23,10 @@ function! tlib#string#RemoveBackslashes(text, ...) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#string#Chomp(string) "{{{3
|
||||
return substitute(a:string, '[[:cntrl:][:space:]]*$', '', '')
|
||||
" :display: tlib#string#Chomp(string, ?max=0)
|
||||
function! tlib#string#Chomp(string, ...) "{{{3
|
||||
let quant = a:0 >= 1 ? '\{,'. a:1 .'}' : '\+'
|
||||
return substitute(a:string, '[[:cntrl:][:space:]]'. quant .'$', '', '')
|
||||
endf
|
||||
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-30.
|
||||
" @Last Change: 2009-02-15.
|
||||
" @Revision: 0.0.23
|
||||
" @Last Change: 2014-07-03.
|
||||
" @Revision: 0.0.26
|
||||
|
||||
if &cp || exists("loaded_tlib_var_autoload")
|
||||
finish
|
||||
@ -58,10 +58,12 @@ endf
|
||||
" echo tlib#var#Get('foo', 'bg') => 2
|
||||
" echo tlib#var#Get('foo', 'wbg') => 3
|
||||
function! tlib#var#Get(var, namespace, ...) "{{{3
|
||||
let var_ = substitute(a:var, '#', '_', 'g')
|
||||
for namespace in split(a:namespace, '\zs')
|
||||
let var = namespace .':'. a:var
|
||||
let vname = namespace == 'g' ? a:var : var_
|
||||
let var = namespace .':'. vname
|
||||
if exists(var)
|
||||
return eval(var)
|
||||
return {var}
|
||||
endif
|
||||
endfor
|
||||
return a:0 >= 1 ? a:1 : ''
|
||||
|
@ -2,8 +2,8 @@
|
||||
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2012-03-08.
|
||||
" @Last Change: 2012-09-10.
|
||||
" @Revision: 122
|
||||
" @Last Change: 2014-07-01.
|
||||
" @Revision: 131
|
||||
|
||||
|
||||
" A dictionarie of supported VCS (currently: git, hg, svn, bzr).
|
||||
@ -49,16 +49,21 @@ if !empty(g:tlib#vcs#check)
|
||||
let g:tlib#vcs#executables[s:cmd] = executable(s:cmd1) ? s:cmd1 : ''
|
||||
endif
|
||||
endfor
|
||||
unlet! s:cmd s:def s:cmd1
|
||||
endif
|
||||
|
||||
|
||||
function! tlib#vcs#Executable(type) "{{{3
|
||||
return get(g:tlib#vcs#executables, a:type, '')
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#vcs#FindVCS(filename) "{{{3
|
||||
let type = ''
|
||||
let dir = ''
|
||||
" let path = escape(fnamemodify(a:filename, ':p'), ',:') .';'
|
||||
let filename = fnamemodify(a:filename, isdirectory(a:filename) ? ':p:h' : ':p')
|
||||
let path = escape(filename, ';') .';'
|
||||
" TLogVAR a:filename, path
|
||||
let dirname = fnamemodify(a:filename, isdirectory(a:filename) ? ':p' : ':p:h')
|
||||
let path = escape(dirname, ';') .';'
|
||||
" TLogVAR a:filename, dirname, path
|
||||
let depth = -1
|
||||
for vcs in keys(g:tlib#vcs#def)
|
||||
let subdir = g:tlib#vcs#def[vcs].dir
|
||||
|
Reference in New Issue
Block a user