mirror of
https://github.com/amix/vimrc
synced 2025-08-07 14:14:59 +08:00
Updated plugins
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
" vcs.vim
|
||||
" @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: 2014-09-30.
|
||||
" @Revision: 133
|
||||
" @Last Change: 2015-11-07.
|
||||
" @Revision: 190
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
|
||||
" A dictionarie of supported VCS (currently: git, hg, svn, bzr).
|
||||
@ -11,7 +12,8 @@
|
||||
TLet g:tlib#vcs#def = {
|
||||
\ 'git': {
|
||||
\ 'dir': '.git',
|
||||
\ 'ls': 'git ls-files --full-name %s',
|
||||
\ 'ls': 'git ls-files --full-name',
|
||||
\ 'ls.postprocess': '*tlib#vcs#GitLsPostprocess',
|
||||
\ 'diff': 'git diff --no-ext-diff -U0 %s'
|
||||
\ },
|
||||
\ 'hg': {
|
||||
@ -64,11 +66,13 @@ function! tlib#vcs#FindVCS(filename) "{{{3
|
||||
let dirname = fnamemodify(a:filename, isdirectory(a:filename) ? ':p' : ':p:h')
|
||||
let path = escape(dirname, ';') .';'
|
||||
" TLogVAR a:filename, dirname, path
|
||||
Tlibtrace 'tlib', a:filename, path
|
||||
let depth = -1
|
||||
for vcs in keys(g:tlib#vcs#def)
|
||||
let subdir = g:tlib#vcs#def[vcs].dir
|
||||
let vcsdir = finddir(subdir, path)
|
||||
" TLogVAR vcs, subdir, vcsdir
|
||||
Tlibtrace 'tlib', vcs, subdir, vcsdir
|
||||
if !empty(vcsdir)
|
||||
let vcsdir_depth = len(split(fnamemodify(vcsdir, ':p'), '\/'))
|
||||
if vcsdir_depth > depth
|
||||
@ -79,6 +83,7 @@ function! tlib#vcs#FindVCS(filename) "{{{3
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
Tlibtrace 'tlib', type, dir
|
||||
" TLogVAR type, dir
|
||||
if empty(type)
|
||||
return ['', '']
|
||||
@ -92,13 +97,17 @@ function! s:GetCmd(vcstype, cmd)
|
||||
let vcsdef = get(g:tlib#vcs#def, a:vcstype, {})
|
||||
if has_key(vcsdef, a:cmd)
|
||||
let cmd = vcsdef[a:cmd]
|
||||
let bin = get(g:tlib#vcs#executables, a:vcstype, '')
|
||||
if empty(bin)
|
||||
let cmd = ''
|
||||
elseif bin != a:vcstype
|
||||
" let bin = escape(shellescape(bin), '\')
|
||||
let bin = escape(bin, '\')
|
||||
let cmd = substitute(cmd, '^.\{-}\zs'. escape(a:vcstype, '\'), bin, '')
|
||||
if cmd =~ '^\*'
|
||||
let cmd = substitute(cmd, '^\*', '', '')
|
||||
else
|
||||
let bin = get(g:tlib#vcs#executables, a:vcstype, '')
|
||||
if empty(bin)
|
||||
let cmd = ''
|
||||
elseif bin != a:vcstype
|
||||
" let bin = escape(shellescape(bin), '\')
|
||||
let bin = escape(bin, '\')
|
||||
let cmd = substitute(cmd, '^.\{-}\zs'. escape(a:vcstype, '\'), bin, '')
|
||||
endif
|
||||
endif
|
||||
return cmd
|
||||
else
|
||||
@ -115,6 +124,7 @@ function! tlib#vcs#Ls(...) "{{{3
|
||||
else
|
||||
let vcs = tlib#vcs#FindVCS(a:0 >= 1 ? a:1 : bufname('%'))
|
||||
endif
|
||||
Tlibtrace 'tlib', vcs, a:000
|
||||
" TLogVAR vcs
|
||||
if !empty(vcs)
|
||||
let [vcstype, vcsdir] = vcs
|
||||
@ -129,11 +139,17 @@ function! tlib#vcs#Ls(...) "{{{3
|
||||
else
|
||||
let cmd = ls
|
||||
endif
|
||||
" TLogVAR cmd
|
||||
let filess = system(cmd)
|
||||
" TLogVAR cmd, getcwd()
|
||||
Tlibtrace 'tlib', getcwd(), vcstype, vcsdir, rootdir, cmd
|
||||
let filess = tlib#sys#SystemInDir(rootdir, cmd)
|
||||
" TLogVAR filess
|
||||
let files = split(filess, '\n')
|
||||
let postprocess = s:GetCmd(vcstype, 'ls.postprocess')
|
||||
if !empty(postprocess)
|
||||
call map(files, 'call(postprocess, [v:val])')
|
||||
endif
|
||||
call map(files, 'join([rootdir, v:val], "/")')
|
||||
" TLogVAR files
|
||||
return files
|
||||
endif
|
||||
endif
|
||||
@ -158,3 +174,16 @@ function! tlib#vcs#Diff(filename, ...) "{{{3
|
||||
return []
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#vcs#GitLsPostprocess(filename) abort "{{{3
|
||||
if a:filename =~ '^".\{-}"$'
|
||||
let filename = matchstr(a:filename, '^"\zs.\{-}\ze"$')
|
||||
let filename = substitute(filename, '\%(\\\@<!\\\(\d\d\d\)\)\+', '\=eval(''"''. submatch(0) .''"'')', 'g')
|
||||
" let filename = eval(a:filename)
|
||||
" TLogVAR a:filename, filename, &enc
|
||||
return filename
|
||||
else
|
||||
return a:filename
|
||||
endif
|
||||
endf
|
||||
|
||||
|
Reference in New Issue
Block a user