1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 01:25:00 +08:00

plugins update

This commit is contained in:
Geezus
2019-05-16 14:48:47 -05:00
parent 5bc3d0226c
commit 555992dd9b
162 changed files with 3534 additions and 1379 deletions

View File

@ -427,8 +427,12 @@ function! s:add_methods(namespace, method_names) abort
endfunction
let s:commands = []
function! s:command(definition) abort
let s:commands += [a:definition]
function! s:command(definition, ...) abort
if a:0
call add(s:commands, a:definition . ' execute s:' . a:1 . "Command(<line1>, <line2>, +'<range>', <count>, <bang>0, '<mods>', <q-reg>, <q-args>, [<f-args>])")
else
call add(s:commands, a:definition)
endif
endfunction
function! s:define_commands() abort
@ -520,7 +524,7 @@ endfunction
call s:add_methods('repo',['prepare','git_command','git_chomp','git_chomp_in_tree','rev_parse'])
function! s:repo_superglob(base) dict abort
return map(fugitive#Complete(a:base, self.git_dir), 'substitute(v:val, ''\\\(.\)'', ''\1'', "g")')
return map(fugitive#CompleteObject(a:base, self.git_dir), 'substitute(v:val, ''\\\(.\)'', ''\1'', "g")')
endfunction
call s:add_methods('repo',['superglob'])
@ -1127,7 +1131,7 @@ function! fugitive#glob(url, ...) abort
let [dirglob, commit, glob] = s:DirCommitFile(a:url)
let append = matchstr(glob, '/*$')
let glob = substitute(glob, '/*$', '', '')
let pattern = '^' . substitute(glob, '/\=\*\*/\=\|/\=\*\|[.?\^$]', '\=get(s:globsubs, submatch(0), "\\" . submatch(0))', 'g')[1:-1] . '$'
let pattern = '^' . substitute(glob, '/\=\*\*/\=\|/\=\*\|[.?\$]\|^^', '\=get(s:globsubs, submatch(0), "\\" . submatch(0))', 'g')[1:-1] . '$'
let results = []
for dir in dirglob =~# '[*?]' ? split(glob(dirglob), "\n") : [dirglob]
if empty(dir) || !get(g:, 'fugitive_file_api', 1) || !filereadable(dir . '/HEAD')
@ -1226,8 +1230,8 @@ function! s:GlobComplete(lead, pattern) abort
return results
endfunction
function! fugitive#PathComplete(base, ...) abort
let dir = a:0 == 1 ? a:1 : s:Dir()
function! fugitive#CompletePath(base, ...) abort
let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir()
let tree = s:Tree(dir) . '/'
let strip = '^\%(:/:\=\|:(top)\|:(top,literal)\|:(literal,top)\|:(literal)\)'
let base = substitute(a:base, strip, '', '')
@ -1253,8 +1257,12 @@ function! fugitive#PathComplete(base, ...) abort
return matches
endfunction
function! fugitive#Complete(base, ...) abort
let dir = a:0 == 1 ? a:1 : s:Dir()
function! fugitive#PathComplete(...) abort
return call('fugitive#CompletePath', a:000)
endfunction
function! fugitive#CompleteObject(base, ...) abort
let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir()
let cwd = a:0 == 1 ? s:Tree(dir) : getcwd()
let tree = s:Tree(dir) . '/'
let subdir = ''
@ -1278,7 +1286,7 @@ function! fugitive#Complete(base, ...) abort
endif
call map(results, 's:fnameescape(v:val)')
if !empty(tree)
let results += a:0 == 1 ? fugitive#PathComplete(a:base, dir) : fugitive#PathComplete(a:base)
let results += a:0 == 1 ? fugitive#CompletePath(a:base, dir) : fugitive#CompletePath(a:base)
endif
return results
@ -1304,9 +1312,13 @@ function! fugitive#Complete(base, ...) abort
return map(entries, 's:fnameescape(v:val)')
endfunction
function! fugitive#Complete(...) abort
return call('fugitive#CompleteObject', a:000)
endfunction
" Section: Buffer auto-commands
function! s:ReplaceCmd(cmd, ...) abort
function! s:ReplaceCmd(cmd) abort
let temp = tempname()
let err = s:TempCmd(temp, a:cmd)
if v:shell_error
@ -1318,11 +1330,7 @@ function! s:ReplaceCmd(cmd, ...) abort
let modelines = &modelines
try
set modelines=0
if a:0
silent keepjumps noautocmd edit!
else
silent keepjumps edit!
endif
silent keepjumps noautocmd edit!
finally
let &modelines = modelines
try
@ -1338,6 +1346,9 @@ endfunction
function! s:QueryLog(refspec) abort
let lines = split(system(FugitivePrepare('log', '-n', '256', '--format=%h%x09%s', a:refspec, '--')), "\n")
if v:shell_error
return []
endif
call map(lines, 'split(v:val, "\t")')
call map(lines, '{"type": "Log", "commit": v:val[0], "subject": v:val[-1]}')
return lines
@ -1580,7 +1591,7 @@ function! fugitive#BufReadStatus() abort
nnoremap <buffer> <silent> P :<C-U>execute <SID>StagePatch(line('.'),line('.')+v:count1-1)<CR>
xnoremap <buffer> <silent> P :<C-U>execute <SID>StagePatch(line("'<"),line("'>"))<CR>
nnoremap <buffer> <silent> q :<C-U>if bufnr('$') == 1<Bar>quit<Bar>else<Bar>bdelete<Bar>endif<CR>
nnoremap <buffer> <silent> gq :<C-U>if bufnr('$') == 1<Bar>quit<Bar>else<Bar>bdelete<Bar>endif<CR>
exe 'nnoremap <buffer> <silent>' nowait "gq :<C-U>if bufnr('$') == 1<Bar>quit<Bar>else<Bar>bdelete<Bar>endif<CR>"
nnoremap <buffer> <silent> R :<C-U>exe <SID>ReloadStatus()<CR>
nnoremap <buffer> <silent> U :<C-U>echoerr 'Changed to X'<CR>
nnoremap <buffer> <silent> g<Bar> :<C-U>execute <SID>StageDelete(line('.'),v:count)<CR>
@ -1821,18 +1832,18 @@ augroup END
" Section: :Git
call s:command("-bang -nargs=? -complete=customlist,s:GitComplete Git :execute s:Git(<bang>0,'<mods>',<q-args>)")
call s:command("-bang -nargs=? -complete=customlist,fugitive#CompleteGit Git", "Git")
function! s:Git(bang, mods, args) abort
function! s:GitCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort
if a:bang
return s:Edit('edit', 1, a:mods, a:args)
return s:Open('edit', 1, a:mods, a:arg, a:args)
endif
let git = s:UserCommand()
if has('gui_running') && !has('win32')
let git .= ' --no-pager'
endif
let args = matchstr(a:args,'\v\C.{-}%($|\\@<!%(\\\\)*\|)@=')
let after = matchstr(a:args, '\v\C\\@<!%(\\\\)*\zs\|.*')
let args = matchstr(a:arg,'\v\C.{-}%($|\\@<!%(\\\\)*\|)@=')
let after = matchstr(a:arg, '\v\C\\@<!%(\\\\)*\zs\|.*')
let tree = s:Tree()
if !s:CanAutoReloadStatus()
let after = '|call fugitive#ReloadStatus()' . after
@ -1866,34 +1877,34 @@ function! s:Subcommands() abort
endfunction
let s:aliases = {}
function! s:Aliases() abort
let dir = s:Dir()
if !has_key(s:aliases, dir)
let s:aliases[dir] = {}
function! s:Aliases(dir) abort
if !has_key(s:aliases, a:dir)
let s:aliases[a:dir] = {}
let lines = split(s:TreeChomp('config','-z','--get-regexp','^alias[.]'),"\1")
for line in v:shell_error ? [] : lines
let s:aliases[dir][matchstr(line, '\.\zs.\{-}\ze\n')] = matchstr(line, '\n\zs.*')
let s:aliases[a:dir][matchstr(line, '\.\zs.\{-}\ze\n')] = matchstr(line, '\n\zs.*')
endfor
endif
return s:aliases[dir]
return s:aliases[a:dir]
endfunction
function! s:GitComplete(A, L, P) abort
let pre = strpart(a:L, 0, a:P)
function! fugitive#CompleteGit(lead, ...) abort
let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir()
let pre = a:0 > 1 ? strpart(a:1, 0, a:2) : ''
if pre !~# ' [[:alnum:]-]\+ '
let cmds = s:Subcommands()
return filter(sort(cmds+keys(s:Aliases())), 'strpart(v:val, 0, strlen(a:A)) ==# a:A')
return filter(sort(cmds+keys(s:Aliases(dir))), 'strpart(v:val, 0, strlen(a:lead)) ==# a:lead')
elseif pre =~# ' -- '
return fugitive#PathComplete(a:A, s:Dir())
return fugitive#CompletePath(a:lead, dir)
else
return fugitive#Complete(a:A, s:Dir())
return fugitive#CompleteObject(a:lead, dir)
endif
endfunction
" Section: :Gcd, :Glcd
function! s:DirComplete(A, L, P) abort
return filter(fugitive#PathComplete(a:A), 'v:val =~# "/$"')
return filter(fugitive#CompletePath(a:A), 'v:val =~# "/$"')
endfunction
function! s:DirArg(path) abort
@ -1910,10 +1921,10 @@ call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Glcd :exe
" Section: :Gstatus
call s:command("-bar -bang -range=-1 Gstatus :execute s:Status(<bang>0, <count>, '<mods>')")
call s:command("-bar -bang -range=-1 G :execute s:Status(<bang>0, <count>, '<mods>')")
call s:command("-bar -bang -range=-1 Gstatus", "Status")
call s:command("-bar -bang -range=-1 G", "Status")
function! s:Status(bang, count, mods) abort
function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort
try
let mods = a:mods ==# '<mods>' || empty(a:mods) ? '' : a:mods . ' '
if mods !~# 'aboveleft\|belowright\|leftabove\|rightbelow\|topleft\|botright'
@ -2635,9 +2646,9 @@ endfunction
" Section: :Gcommit
call s:command("-nargs=? -complete=customlist,s:CommitComplete Gcommit :execute s:Commit('<mods>', <q-args>)")
call s:command("-nargs=? -complete=customlist,s:CommitComplete Gcommit", "Commit")
function! s:Commit(mods, args, ...) abort
function! s:CommitCommand(line1, line2, range, count, bang, mods, reg, arg, args, ...) abort
let mods = s:gsub(a:mods ==# '<mods>' ? '' : a:mods, '<tab>', '-tab')
let dir = a:0 ? a:1 : s:Dir()
let tree = s:Tree(dir)
@ -2658,11 +2669,11 @@ function! s:Commit(mods, args, ...) abort
else
let command = 'env GIT_EDITOR=false '
endif
let args = s:ShellExpand(a:args)
let args = s:ShellExpand(a:arg)
let command .= s:UserCommand() . ' commit ' . args
if &shell =~# 'csh'
noautocmd silent execute '!('.escape(command, '!#%').' > '.outfile.') >& '.errorfile
elseif a:args =~# '\%(^\| \)-\%(-interactive\|p\|-patch\)\>'
elseif a:arg =~# '\%(^\| \)-\%(-interactive\|p\|-patch\)\>'
noautocmd execute '!'.command.' 2> '.errorfile
else
noautocmd silent execute '!'.command.' > '.outfile.' 2> '.errorfile
@ -2696,7 +2707,7 @@ function! s:Commit(mods, args, ...) abort
endif
if bufname('%') == '' && line('$') == 1 && getline(1) == '' && !&mod
execute mods 'keepalt edit' s:fnameescape(msgfile)
elseif a:args =~# '\%(^\| \)-\w*v' || mods =~# '\<tab\>'
elseif a:arg =~# '\%(^\| \)-\w*v' || mods =~# '\<tab\>'
execute mods 'keepalt -tabedit' s:fnameescape(msgfile)
else
execute mods 'keepalt split' s:fnameescape(msgfile)
@ -2733,7 +2744,7 @@ function! s:CommitComplete(A,L,P) abort
let args = ['-C', '-F', '-a', '-c', '-e', '-i', '-m', '-n', '-o', '-q', '-s', '-t', '-u', '-v', '--all', '--allow-empty', '--amend', '--author=', '--cleanup=', '--dry-run', '--edit', '--file=', '--fixup=', '--include', '--interactive', '--message=', '--no-verify', '--only', '--quiet', '--reedit-message=', '--reuse-message=', '--signoff', '--squash=', '--template=', '--untracked-files', '--verbose']
return filter(args,'v:val[0 : strlen(a:A)-1] ==# a:A')
else
return fugitive#PathComplete(a:A, s:Dir())
return fugitive#CompletePath(a:A, s:Dir())
endif
return []
endfunction
@ -2747,7 +2758,7 @@ function! s:FinishCommit() abort
call setbufvar(buf, 'fugitive_commit_rebase', 0)
let s:rebase_continue = s:Dir(buf)
endif
return s:Commit('', args, s:Dir(buf))
return s:CommitCommand(-1, -1, 0, -1, 0, '', '', args, [], s:Dir(buf))
endif
return ''
endfunction
@ -2848,6 +2859,16 @@ function! s:Merge(cmd, bang, mods, args, ...) abort
return s:RebaseEdit(mods . 'split', dir)
elseif a:cmd =~# '^rebase' && ' '.a:args =~# ' --edit-todo' && filereadable(dir . '/rebase-merge/git-rebase-todo')
return s:RebaseEdit(mods . 'split', dir)
elseif a:cmd =~# '^rebase' && ' '.a:args =~# ' --continue' && !a:0
let rdir = dir . '/rebase-merge'
call system(fugitive#Prepare(dir, 'diff-index', '--cached', '--quiet', 'HEAD', '--'))
if v:shell_error && isdirectory(rdir)
if getfsize(rdir . '/amend') <= 0
return 'exe ' . string(mods . 'Gcommit -n -F ' . s:shellesc(dir . '/rebase-merge/message') . ' -e') . '|let b:fugitive_commit_rebase = 1'
elseif readfile(rdir . '/amend')[0] ==# fugitive#Head(-1, dir)
return 'exe ' . string(mods . 'Gcommit --amend -n -F ' . s:shellesc(dir . '/rebase-merge/message') . ' -e') . '|let b:fugitive_commit_rebase = 1'
endif
endif
endif
let [mp, efm] = [&l:mp, &l:efm]
let had_merge_msg = filereadable(dir . '/MERGE_MSG')
@ -2906,7 +2927,7 @@ function! s:Merge(cmd, bang, mods, args, ...) abort
let $GIT_EDITOR = old_editor
endif
if exists('old_sequence_editor')
let $GIT_SEQUENCE_EDITOR = old_editor
let $GIT_SEQUENCE_EDITOR = old_sequence_editor
endif
execute cdback
endtry
@ -2979,9 +3000,9 @@ endif
function! s:GrepComplete(A, L, P) abort
if strpart(a:L, 0, a:P) =~# ' -- '
return fugitive#PathComplete(a:A, s:Dir())
return fugitive#CompletePath(a:A, s:Dir())
else
return fugitive#Complete(a:A, s:Dir())
return fugitive#CompleteObject(a:A, s:Dir())
endif
endfunction
@ -3084,7 +3105,7 @@ function! s:UsableWin(nr) abort
\ index(['nofile','help','quickfix'], getbufvar(winbufnr(a:nr), '&buftype')) < 0
endfunction
function! s:EditParse(args) abort
function! s:OpenParse(args) abort
let pre = []
let args = copy(a:args)
while !empty(args) && args[0] =~# '^+'
@ -3126,7 +3147,7 @@ function! s:BlurStatus() abort
endif
endfunction
function! s:Edit(cmd, bang, mods, args, ...) abort
function! s:Open(cmd, bang, mods, arg, args) abort
let mods = a:mods ==# '<mods>' ? '' : a:mods
if a:bang
@ -3134,7 +3155,7 @@ function! s:Edit(cmd, bang, mods, args, ...) abort
try
let cdback = s:Cd(s:Tree())
let git = s:UserCommand()
let args = s:ShellExpand(a:args)
let args = s:ShellExpand(a:arg)
silent! execute '!' . escape(git . ' --no-pager ' . args, '!#%') .
\ (&shell =~# 'csh' ? ' >& ' . temp : ' > ' . temp . ' 2>&1')
finally
@ -3150,7 +3171,7 @@ function! s:Edit(cmd, bang, mods, args, ...) abort
return 'redraw|echo ' . string(':!' . git . ' ' . args)
endif
let [file, pre] = s:EditParse(a:000)
let [file, pre] = s:OpenParse(a:args)
try
let file = s:Generate(file)
catch /^fugitive:/
@ -3165,7 +3186,7 @@ function! s:Edit(cmd, bang, mods, args, ...) abort
return mods . ' ' . a:cmd . pre . ' ' . s:fnameescape(file)
endfunction
function! s:Read(count, line1, line2, range, bang, mods, args, ...) abort
function! s:ReadCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort
let mods = a:mods ==# '<mods>' ? '' : a:mods
let after = a:line2
if a:count < 0
@ -3180,7 +3201,7 @@ function! s:Read(count, line1, line2, range, bang, mods, args, ...) abort
try
let cdback = s:Cd(s:Tree())
let git = s:UserCommand()
let args = s:ShellExpand(a:args)
let args = s:ShellExpand(a:arg)
silent execute mods after.'read!' escape(git . ' --no-pager ' . args, '!#%')
finally
execute cdback
@ -3189,7 +3210,7 @@ function! s:Read(count, line1, line2, range, bang, mods, args, ...) abort
call fugitive#ReloadStatus()
return 'redraw|echo '.string(':!'.git.' '.args)
endif
let [file, pre] = s:EditParse(a:000)
let [file, pre] = s:OpenParse(a:args)
try
let file = s:Generate(file)
catch /^fugitive:/
@ -3204,29 +3225,29 @@ function! s:Read(count, line1, line2, range, bang, mods, args, ...) abort
return mods . ' ' . after . 'read' . pre . ' ' . s:fnameescape(file) . '|' . delete . 'diffupdate' . (a:count < 0 ? '|' . line('.') : '')
endfunction
function! s:EditRunComplete(A,L,P) abort
function! s:ReadComplete(A,L,P) abort
if a:L =~# '^\w\+!'
return s:GitComplete(a:A, a:L, a:P)
return fugitive#CompleteGit(a:A, a:L, a:P)
else
return fugitive#Complete(a:A, a:L, a:P)
return fugitive#CompleteObject(a:A, a:L, a:P)
endif
endfunction
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#Complete Ge execute s:Edit('edit<bang>', 0, '<mods>', <q-args>, <f-args>)")
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#Complete Gedit execute s:Edit('edit<bang>', 0, '<mods>', <q-args>, <f-args>)")
call s:command("-bar -bang -nargs=* -complete=customlist,s:EditRunComplete Gpedit execute s:Edit('pedit', <bang>0, '<mods>', <q-args>, <f-args>)")
call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:EditRunComplete Gsplit execute s:Edit((<count> > 0 ? <count> : '').(<count> ? 'split' : 'edit'), <bang>0, '<mods>', <q-args>, <f-args>)")
call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:EditRunComplete Gvsplit execute s:Edit((<count> > 0 ? <count> : '').(<count> ? 'vsplit' : 'edit!'), <bang>0, '<mods>', <q-args>, <f-args>)")
call s:command("-bar -bang -nargs=* -range=0 -complete=customlist,s:EditRunComplete" . (has('patch-7.4.542') ? ' -addr=tabs' : '') . " Gtabedit execute s:Edit((<count> ? <count> : '').'tabedit', <bang>0, '<mods>', <q-args>, <f-args>)")
call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:EditRunComplete Gread execute s:Read(<count>, <line1>, <line2>, +'<range>', <bang>0, '<mods>', <q-args>, <f-args>)")
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Ge execute s:Open('edit<bang>', 0, '<mods>', <q-args>, [<f-args>])")
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Gedit execute s:Open('edit<bang>', 0, '<mods>', <q-args>, [<f-args>])")
call s:command("-bar -bang -nargs=* -complete=customlist,s:ReadComplete Gpedit execute s:Open('pedit', <bang>0, '<mods>', <q-args>, [<f-args>])")
call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:ReadComplete Gsplit execute s:Open((<count> > 0 ? <count> : '').(<count> ? 'split' : 'edit'), <bang>0, '<mods>', <q-args>, [<f-args>])")
call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:ReadComplete Gvsplit execute s:Open((<count> > 0 ? <count> : '').(<count> ? 'vsplit' : 'edit!'), <bang>0, '<mods>', <q-args>, [<f-args>])")
call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:ReadComplete" . (has('patch-7.4.542') ? ' -addr=tabs' : '') . " Gtabedit execute s:Open((<count> >= 0 ? <count> : '').'tabedit', <bang>0, '<mods>', <q-args>, [<f-args>])")
call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:ReadComplete Gread", "Read")
" Section: :Gwrite, :Gwq
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#Complete Gwrite :execute s:Write(<bang>0,<f-args>)")
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#Complete Gw :execute s:Write(<bang>0,<f-args>)")
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#Complete Gwq :execute s:Wq(<bang>0,<f-args>)")
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Gwrite", "Write")
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Gw", "Write")
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Gwq", "Wq")
function! s:Write(force,...) abort
function! s:WriteCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort
if exists('b:fugitive_commit_arguments')
return 'write|bdelete'
elseif expand('%:t') == 'COMMIT_EDITMSG' && $GIT_INDEX_FILE != ''
@ -3246,7 +3267,7 @@ function! s:Write(force,...) abort
if err !=# ''
let v:errmsg = split(err,"\n")[0]
return 'echoerr v:errmsg'
elseif a:force
elseif a:bang
return 'bdelete'
else
return 'Gedit '.fnameescape(filename)
@ -3254,15 +3275,15 @@ function! s:Write(force,...) abort
endif
let mytab = tabpagenr()
let mybufnr = bufnr('')
let file = a:0 ? s:Generate(s:Expand(join(a:000, ' '))) : fugitive#Real(@%)
let file = len(a:args) ? s:Generate(s:Expand(join(a:args, ' '))) : fugitive#Real(@%)
if empty(file)
return 'echoerr '.string('fugitive: cannot determine file path')
endif
if file =~# '^fugitive:'
return 'write' . (a:force ? '! ' : ' ') . s:fnameescape(file)
return 'write' . (a:bang ? '! ' : ' ') . s:fnameescape(file)
endif
let always_permitted = s:cpath(fugitive#Real(@%), file) && s:DirCommitFile(@%)[1] =~# '^0\=$'
if !always_permitted && !a:force && (len(s:TreeChomp('diff', '--name-status', 'HEAD', '--', file)) || len(s:TreeChomp('ls-files', '--others', '--', file)))
if !always_permitted && !a:bang && (len(s:TreeChomp('diff', '--name-status', 'HEAD', '--', file)) || len(s:TreeChomp('ls-files', '--others', '--', file)))
let v:errmsg = 'fugitive: file has uncommitted changes (use ! to override)'
return 'echoerr v:errmsg'
endif
@ -3308,7 +3329,7 @@ function! s:Write(force,...) abort
execute 'write! '.s:fnameescape(file)
endif
if a:force
if a:bang
let error = s:TreeChomp('add', '--force', '--', file)
else
let error = s:TreeChomp('add', '--', file)
@ -3366,12 +3387,12 @@ function! s:Write(force,...) abort
return 'checktime'
endfunction
function! s:Wq(force,...) abort
let bang = a:force ? '!' : ''
function! s:WqCommand(...) abort
let bang = a:5 ? '!' : ''
if exists('b:fugitive_commit_arguments')
return 'wq'.bang
endif
let result = call(s:function('s:Write'),[a:force]+a:000)
let result = call(s:function('s:WriteCommand'),a:000)
if result =~# '^\%(write\|wq\|echoerr\)'
return s:sub(result,'^write','wq')
else
@ -3413,9 +3434,9 @@ endfunction
" Section: :Gdiff
call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#Complete Gdiff :execute s:Diff('',<bang>0,<f-args>)")
call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#Complete Gvdiff :execute s:Diff('keepalt vert ',<bang>0,<f-args>)")
call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#Complete Gsdiff :execute s:Diff('keepalt ',<bang>0,<f-args>)")
call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#CompleteObject Gdiff :execute s:Diff('',<bang>0,<f-args>)")
call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#CompleteObject Gvdiff :execute s:Diff('keepalt vert ',<bang>0,<f-args>)")
call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#CompleteObject Gsdiff :execute s:Diff('keepalt ',<bang>0,<f-args>)")
augroup fugitive_diff
autocmd!
@ -3655,10 +3676,10 @@ endfunction
function! s:RenameComplete(A,L,P) abort
if a:A =~# '^[.:]\=/'
return fugitive#PathComplete(a:A)
return fugitive#CompletePath(a:A)
else
let pre = s:Slash(fnamemodify(expand('%:p:s?[\/]$??'), ':h')) . '/'
return map(fugitive#PathComplete(pre.a:A), 'strpart(v:val, len(pre))')
return map(fugitive#CompletePath(pre.a:A), 'strpart(v:val, len(pre))')
endif
endfunction
@ -3687,7 +3708,7 @@ endfunction
augroup fugitive_remove
autocmd!
autocmd User Fugitive if s:DirCommitFile(@%)[1] =~# '^0\=$' |
\ exe "command! -buffer -bar -bang -nargs=1 -complete=customlist,fugitive#PathComplete Gmove :execute s:Move(<bang>0,0,<q-args>)" |
\ exe "command! -buffer -bar -bang -nargs=1 -complete=customlist,fugitive#CompletePath Gmove :execute s:Move(<bang>0,0,<q-args>)" |
\ exe "command! -buffer -bar -bang -nargs=1 -complete=customlist,s:RenameComplete Grename :execute s:Move(<bang>0,1,<q-args>)" |
\ exe "command! -buffer -bar -bang Gremove :execute s:Remove('edit',<bang>0)" |
\ exe "command! -buffer -bar -bang Gdelete :execute s:Remove('bdelete',<bang>0)" |
@ -3711,7 +3732,7 @@ augroup fugitive_blame
autocmd Syntax fugitiveblame call s:BlameSyntax()
autocmd User Fugitive
\ if get(b:, 'fugitive_type') =~# '^\%(file\|blob\|blame\)$' || filereadable(@%) |
\ exe "command! -buffer -bar -bang -range=0 -nargs=* Gblame :execute s:Blame(<bang>0,<line1>,<line2>,<count>,'<mods>',[<f-args>])" |
\ exe "command! -buffer -bar -bang -range=0 -nargs=* Gblame :execute s:BlameCommand(<line1>,<line2>,+'<range>',<count>,<bang>0,'<mods>',<q-reg>,<q-args>,[<f-args>])" |
\ endif
autocmd ColorScheme,GUIEnter * call s:RehighlightBlame()
autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('<abuf>')), 'fugitive_leave')
@ -3727,7 +3748,7 @@ function! s:linechars(pattern) abort
return chars
endfunction
function! s:Blame(bang, line1, line2, count, mods, args) abort
function! s:BlameCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort
if exists('b:fugitive_blamed_bufnr')
return 'bdelete'
endif
@ -3735,7 +3756,7 @@ function! s:Blame(bang, line1, line2, count, mods, args) abort
if empty(s:Relative('/'))
call s:throw('file or blob required')
endif
if filter(copy(a:args),'v:val !~# "^\\%(--relative-date\\|--first-parent\\|--root\\|--show-name\\|-\\=\\%([ltfnsew]\\|[MC]\\d*\\)\\+\\)$"') != []
if filter(copy(a:args),'v:val !~# "^\\%(--abbrev=\\d*\\|--relative-date\\|--first-parent\\|--root\\|--show-name\\|-\\=\\%([ltfnsew]\\|[MC]\\d*\\)\\+\\)$"') != []
call s:throw('unsupported option')
endif
call map(a:args,'s:sub(v:val,"^\\ze[^-]","-")')
@ -3818,10 +3839,11 @@ function! s:Blame(bang, line1, line2, count, mods, args) abort
setlocal norelativenumber
endif
execute "vertical resize ".(s:linechars('.\{-\}\ze\s\+\d\+)')+1)
let nowait = v:version >= 704 ? '<nowait>' : ''
nnoremap <buffer> <silent> <F1> :help fugitive-:Gblame<CR>
nnoremap <buffer> <silent> g? :help fugitive-:Gblame<CR>
nnoremap <buffer> <silent> q :exe substitute(bufwinnr(b:fugitive_blamed_bufnr).' wincmd w<Bar>'.bufnr('').'bdelete','^-1','','')<CR>
nnoremap <buffer> <silent> gq :exe substitute(bufwinnr(b:fugitive_blamed_bufnr).' wincmd w<Bar>'.bufnr('').'bdelete<Bar>if expand("%:p") =~# "^fugitive:[\\/][\\/]"<Bar>Gedit<Bar>endif','^-1','','')<CR>
exe 'nnoremap <buffer> <silent>' nowait "gq :exe substitute(bufwinnr(b:fugitive_blamed_bufnr).' wincmd w<Bar>'.bufnr('').'bdelete<Bar>if expand(''%:p'') =~# ''^fugitive:[\\/][\\/]''<Bar>Gedit<Bar>endif','^-1','','')<CR>"
nnoremap <buffer> <silent> <CR> :<C-U>exe <SID>BlameCommit("exe 'norm q'<Bar>edit")<CR>
nnoremap <buffer> <silent> - :<C-U>exe <SID>BlameJump('')<CR>
nnoremap <buffer> <silent> P :<C-U>exe <SID>BlameJump('^'.v:count1)<CR>
@ -3829,7 +3851,7 @@ function! s:Blame(bang, line1, line2, count, mods, args) abort
nnoremap <buffer> <silent> i :<C-U>exe <SID>BlameCommit("exe 'norm q'<Bar>edit")<CR>
nnoremap <buffer> <silent> o :<C-U>exe <SID>BlameCommit((&splitbelow ? "botright" : "topleft")." split")<CR>
nnoremap <buffer> <silent> O :<C-U>exe <SID>BlameCommit("tabedit")<CR>
nnoremap <buffer> <silent> p :<C-U>exe <SID>Edit((&splitbelow ? "botright" : "topleft").' pedit', 0, '', matchstr(getline('.'), '\x\+'), matchstr(getline('.'), '\x\+'))<CR>
nnoremap <buffer> <silent> p :<C-U>exe <SID>Open((&splitbelow ? "botright" : "topleft").' pedit', 0, '', matchstr(getline('.'), '\x\+'), [matchstr(getline('.'), '\x\+')])<CR>
nnoremap <buffer> <silent> A :<C-u>exe "vertical resize ".(<SID>linechars('.\{-\}\ze [0-9:/+-][0-9:/+ -]* \d\+)')+1+v:count)<CR>
nnoremap <buffer> <silent> C :<C-u>exe "vertical resize ".(<SID>linechars('^\S\+')+1+v:count)<CR>
nnoremap <buffer> <silent> D :<C-u>exe "vertical resize ".(<SID>linechars('.\{-\}\ze\d\ze\s\+\d\+)')+1-v:count)<CR>
@ -3848,7 +3870,7 @@ function! s:BlameCommit(cmd, ...) abort
if line =~# '^0\{4,40\} '
return 'echoerr ' . string('Not Committed Yet')
endif
let cmd = s:Edit(a:cmd, 0, '', matchstr(line, '\x\+'), matchstr(line, '\x\+'))
let cmd = s:Open(a:cmd, 0, '', matchstr(line, '\x\+'), [matchstr(line, '\x\+')])
if cmd =~# '^echoerr'
return cmd
endif
@ -3992,17 +4014,17 @@ endfunction
" Section: :Gbrowse
call s:command("-bar -bang -range=0 -nargs=* -complete=customlist,fugitive#Complete Gbrowse :execute s:Browse(<bang>0,<line1>,<count>,<f-args>)")
call s:command("-bar -bang -range=0 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse", "Browse")
let s:redirects = {}
function! s:Browse(bang,line1,count,...) abort
function! s:BrowseCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort
let dir = s:Dir()
try
let validremote = '\.\|\.\=/.*\|[[:alnum:]_-]\+\%(://.\{-\}\)\='
if a:0
let remote = matchstr(join(a:000, ' '),'@\zs\%('.validremote.'\)$')
let rev = substitute(join(a:000, ' '),'@\%('.validremote.'\)$','','')
if len(a:args)
let remote = matchstr(join(a:args, ' '),'@\zs\%('.validremote.'\)$')
let rev = substitute(join(a:args, ' '),'@\%('.validremote.'\)$','','')
else
let remote = ''
let rev = ''
@ -4110,7 +4132,7 @@ function! s:Browse(bang,line1,count,...) abort
if v:shell_error
let commit = ''
endif
if a:count && !a:0 && commit =~# '^\x\{40\}$'
if a:count && empty(a:args) && commit =~# '^\x\{40\}$'
let blame_list = tempname()
call writefile([commit, ''], blame_list, 'b')
let blame_in = tempname()