mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -4,7 +4,7 @@
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-30.
|
||||
" @Last Change: 2011-03-18.
|
||||
" @Revision: 53
|
||||
" @Revision: 57
|
||||
|
||||
|
||||
""" List related functions {{{1
|
||||
@ -166,3 +166,15 @@ function! tlib#list#Uniq(list, ...) "{{{3
|
||||
return uniques
|
||||
endf
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
127
sources_non_forked/tlib/autoload/tlib/sys.vim
Normal file
127
sources_non_forked/tlib/autoload/tlib/sys.vim
Normal file
@ -0,0 +1,127 @@
|
||||
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Last Change: 2014-06-30.
|
||||
" @Revision: 25
|
||||
|
||||
|
||||
if !exists('g:tlib#sys#windows')
|
||||
let g:tlib#sys#windows = &shell !~ 'sh' && (has('win16') || has('win32') || has('win64')) "{{{2
|
||||
endif
|
||||
|
||||
|
||||
if !exists('g:tlib#sys#null')
|
||||
let g:tlib#sys#null = g:tlib#sys#windows ? 'NUL' : (filereadable('/dev/null') ? '/dev/null' : '') "{{{2
|
||||
endif
|
||||
|
||||
|
||||
let s:executables = {}
|
||||
|
||||
function! tlib#sys#IsExecutable(cmd, ...) "{{{3
|
||||
" TLogVAR a:cmd
|
||||
" echom "DBG has_key(s:executables, a:cmd)" has_key(s:executables, a:cmd)
|
||||
if !has_key(s:executables, a:cmd)
|
||||
let executable = executable(a:cmd)
|
||||
" TLogVAR 1, executable
|
||||
let ignore_cyg = a:0 >= 1 ? a:1 : !g:tlib#sys#windows
|
||||
if !executable && !ignore_cyg
|
||||
let executable = tlib#sys#IsCygwinBin(a:cmd)
|
||||
" TLogVAR 2, executable
|
||||
endif
|
||||
let s:executables[a:cmd] = executable
|
||||
endif
|
||||
" echom "DBG s:executables[a:cmd]" s:executables[a:cmd]
|
||||
return s:executables[a:cmd]
|
||||
endf
|
||||
|
||||
|
||||
if !exists('g:tlib#sys#check_cygpath')
|
||||
" If true, check whether we have to convert a path via cyppath --
|
||||
" see |tlib#sys#MaybeUseCygpath|
|
||||
let g:tlib#sys#check_cygpath = g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath') "{{{2
|
||||
endif
|
||||
|
||||
|
||||
if !exists('g:tlib#sys#cygwin_path_rx')
|
||||
" If a full windows filename (with slashes instead of backslashes)
|
||||
" matches this |regexp|, it is assumed to be a cygwin executable.
|
||||
let g:tlib#sys#cygwin_path_rx = '/cygwin/' "{{{2
|
||||
endif
|
||||
|
||||
|
||||
if !exists('g:tlib#sys#cygwin_expr')
|
||||
" For cygwin binaries, convert command calls using this vim
|
||||
" expression.
|
||||
let g:tlib#sys#cygwin_expr = '"bash -c ''". escape(%s, "''\\") ."''"' "{{{2
|
||||
endif
|
||||
|
||||
|
||||
let s:cygwin = {}
|
||||
|
||||
function! tlib#sys#IsCygwinBin(cmd) "{{{3
|
||||
" TLogVAR a:cmd
|
||||
if !g:tlib#sys#windows
|
||||
return 0
|
||||
elseif has_key(s:cygwin, a:cmd)
|
||||
let rv = s:cygwin[a:cmd]
|
||||
else
|
||||
if !tlib#sys#IsExecutable('cygpath', 1) || !tlib#sys#IsExecutable('which', 1)
|
||||
let rv = 0
|
||||
else
|
||||
let which = substitute(system('which '. shellescape(a:cmd)), '\n$', '', '')
|
||||
" echom "DBG which:" which
|
||||
if which =~ '^/'
|
||||
let filename = system('cygpath -ma '. shellescape(which))
|
||||
" echom "DBG filename:" filename
|
||||
let rv = filename =~ g:tlib#sys#cygwin_path_rx
|
||||
else
|
||||
let rv = 0
|
||||
endif
|
||||
endif
|
||||
let s:cygwin[a:cmd] = rv
|
||||
endif
|
||||
" TLogVAR rv
|
||||
return rv
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#sys#GetCmd(cmd) "{{{3
|
||||
if !empty(g:tlib#sys#cygwin_expr) && tlib#sys#IsCygwinBin(matchstr(a:cmd, '^\S\+'))
|
||||
let cmd = eval(printf(g:tlib#sys#cygwin_expr, string(a:cmd)))
|
||||
" TLogVAR cmd
|
||||
return cmd
|
||||
else
|
||||
return a:cmd
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" If cmd seems to be a cygwin executable, use cygpath to convert
|
||||
" filenames. This assumes that cygwin's which command returns full
|
||||
" filenames for non-cygwin executables.
|
||||
function! tlib#sys#MaybeUseCygpath(cmd) "{{{3
|
||||
" echom "DBG" a:cmd
|
||||
if g:tlib#sys#check_cygpath && tlib#sys#IsCygwinBin(a:cmd)
|
||||
return 'cygpath -u "%s"'
|
||||
endif
|
||||
return ''
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#sys#ConvertPath(converter, filename) "{{{3
|
||||
return tlib#string#Chomp(system(printf(a:converter, shellescape(a:filename))))
|
||||
endf
|
||||
|
||||
|
||||
let s:native_filenames = {}
|
||||
|
||||
function! tlib#sys#FileArgs(cmd, files) "{{{3
|
||||
let cygpath = tlib#sys#MaybeUseCygpath(a:cmd)
|
||||
" TLogVAR cygpath
|
||||
if empty(cygpath)
|
||||
return a:files
|
||||
else
|
||||
let files = map(copy(a:files), 'has_key(s:native_filenames, v:val) ? s:native_filenames[v:val] : tlib#sys#CygPath(v:val)')
|
||||
return files
|
||||
endif
|
||||
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