20 Commits

Author SHA1 Message Date
Tim Pope
5a24c25275 fugitive.vim 3.6
* Fix support for older Vim 7 patch levels.
* Support copies on :Gclog --follow.
2021-11-25 14:53:57 -05:00
Tim Pope
e82332ee9e Try to avoid trailing newline blame issues
Resolves: https://github.com/tpope/vim-fugitive/issues/1892
2021-11-22 13:24:21 -05:00
Tim Pope
64bc1a3431 Remove dead code
The use of remove() here wouldn't actually work as it expects an index,
not a value.
2021-11-19 17:42:33 -05:00
Tim Pope
4a8db6b856 Support copies with :Gclog --follow
Resolves: https://github.com/tpope/vim-fugitive/issues/1891
2021-11-19 17:19:30 -05:00
Tim Pope
3d5d23fe80 Remove q map stubs
Resolves: https://github.com/tpope/vim-fugitive/issues/1890
2021-11-19 17:16:36 -05:00
Tim Pope
2dfaf17f9e Use dummy events to prevent "No matching autocommands" message
This list of events was hand-curated to eliminate events already defined
elsewhere in the autoload file.

Resolves: https://github.com/tpope/vim-fugitive/issues/1887
2021-11-16 16:09:59 -05:00
Tim Pope
69ae31d402 Fix command execution on Vim 7
This worked on my test environment of 7.4.888, but did not work on
7.4.000.

References: https://github.com/tpope/vim-fugitive/issues/1889
2021-11-16 13:44:55 -05:00
Tim Pope
f9c0b8eafe Fix readfile() usage
Resolves: https://github.com/tpope/vim-fugitive/issues/1886
2021-11-15 20:54:19 -05:00
Tim Pope
e47121f8fd Fix typo 2021-11-15 00:31:32 -05:00
Tim Pope
cd67d087df fugitive.vim 3.5
* Lazy initialization.
* Make status buffer diff retrieval asynchronous.
* Support jump to diff from :Git log --name-status.
* Use smudge filters when viewing blobs.
* Provide User FugitiveEditor event.
* Provide FugitiveRemote() API function.
2021-11-15 00:17:52 -05:00
Tim Pope
b736e457b3 Provide FugitiveRemote() 2021-11-13 16:25:36 -05:00
Tim Pope
2e4ee0b5d6 Don't scroll :Git! window for paginated commands
References: https://github.com/tpope/vim-fugitive/issues/1832
2021-11-11 00:44:14 -05:00
Tim Pope
a6b823b8d0 Fix race condition on nvim 0.4
I could have sworn this wasn't necessary on 0.4, which is why I added
the extra clause, but I can consistently reproduce E716 now.

Resolves: https://github.com/tpope/vim-fugitive/issues/1881
2021-11-02 14:07:58 -04:00
Tim Pope
174fd6a39b Revert "Use :redrawstatus rather than &ro = &ro"
Turns out :redrawstatus is a lot more aggressive and can prevent seeing
Fugitive output.

This reverts commit 6ad15506cc.

References: https://github.com/tpope/vim-fugitive/issues/1180
2021-10-27 03:17:44 -04:00
Tim Pope
6ad15506cc Use :redrawstatus rather than &ro = &ro
References: https://github.com/tpope/vim-fugitive/issues/1180
2021-10-26 09:22:33 -04:00
Tim Pope
30933405bb Support blame maps without filetype plugin on
References: https://github.com/tpope/vim-fugitive/issues/1745
2021-10-19 11:44:22 -04:00
Tim Pope
4d29c1d6a0 Provide for retrieving parsed remote URL
The plan is to expose this as FugitiveRemote(), but let's give it some
bake time before making it official.
2021-10-17 20:25:23 -04:00
Tim Pope
93f41ace7d Move to beginning of line in "(" map
Resolves: https://github.com/tpope/vim-fugitive/issues/1867
2021-10-17 11:22:10 -04:00
Tim Pope
d5a6419fcf Guard against parallel status reload
Resolves: https://github.com/tpope/vim-fugitive/issues/1863
2021-10-17 11:22:10 -04:00
Tim Pope
88c7f867cf Further decouple #BufReadStatus() from v:cmdbang 2021-10-16 12:58:13 -04:00
2 changed files with 164 additions and 108 deletions

View File

@@ -228,7 +228,7 @@ function! s:Map(mode, lhs, rhs, ...) abort
endwhile
if !skip && (flags !~# '<unique>' || empty(mapcheck(head.tail, mode)))
call add(maps, mode.'map <buffer>' . s:nowait . substitute(flags, '<unique>', '', '') . ' ' . head.tail . ' ' . a:rhs)
if a:0 > 1
if a:0 > 1 && a:2
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') .
\ '|sil! exe "' . mode . 'unmap <buffer> ' . head.tail . '"'
endif
@@ -263,7 +263,7 @@ function! fugitive#Wait(job_or_jobs, ...) abort
if exists('*jobwait')
call map(copy(jobs), 'chanclose(v:val, "stdin")')
call jobwait(jobs, timeout_ms)
if len(jobs) && has('nvim-0.5')
if len(jobs)
sleep 1m
endif
else
@@ -341,12 +341,19 @@ function! s:JobExecute(argv, jopts, stdin, callback, ...) abort
let cmd = s:shellesc(a:argv)
let outfile = tempname()
try
let dict.stderr = split(system(' (' . cmd . ' >' . outfile . ') ', join(a:stdin, "\n")), "\n", 1)
if len(a:stdin)
call writefile(a:stdin, outfile . '.in', 'b')
let cmd = ' (' . cmd . ' >' . outfile . ' <' . outfile . '.in) '
else
let cmd = ' (' . cmd . ' >' . outfile . ') '
endif
let dict.stderr = split(system(cmd), "\n", 1)
let dict.exit_status = v:shell_error
let dict.stdout = readfile(outfile, 'b')
call call(cb[0], [dict] + cb[1:-1])
finally
call delete(outfile)
call delete(outfile . '.in')
endtry
endif
if empty(a:callback)
@@ -474,7 +481,7 @@ function! fugitive#CommonDir(dir) abort
if getfsize(a:dir . '/HEAD') < 10
let s:commondirs[a:dir] = ''
elseif filereadable(a:dir . '/commondir')
let cdir = get(readfile(a:dir . '/commondir', 1), 0, '')
let cdir = get(readfile(a:dir . '/commondir', '', 1), 0, '')
if cdir =~# '^/\|^\a:/'
let s:commondirs[a:dir] = s:Slash(FugitiveVimPath(cdir))
else
@@ -1272,15 +1279,15 @@ function! s:UrlParse(url) abort
return url
endfunction
function! s:ResolveRemote(url) abort
function! s:RemoteResolve(url, flags) abort
let remote = s:UrlParse(a:url)
if remote.scheme =~# '^https\=$'
if remote.scheme =~# '^https\=$' && index(a:flags, ':nohttp') < 0
let headers = fugitive#RemoteHttpHeaders(remote.scheme . '://' . remote.authority . remote.path)
let loc = matchstr(get(headers, 'location', ''), '^https\=://.\{-\}\ze/info/refs?')
if len(loc)
let remote = s:UrlParse(loc)
else
let remote.http_headers = headers
let remote.headers = headers
endif
elseif remote.scheme ==# 'ssh'
let remote.authority = fugitive#SshHostAlias(remote.authority)
@@ -1288,23 +1295,66 @@ function! s:ResolveRemote(url) abort
return remote
endfunction
function! fugitive#ResolveRemote(url) abort
let remote = s:ResolveRemote(a:url)
if remote.scheme ==# 'file' || remote.scheme ==# ''
return remote.path
elseif remote.path =~# '^/'
return remote.scheme . '://' . remote.authority . remote.path
elseif remote.path =~# '^\~'
return remote.scheme . '://' . remote.authority . '/' . remote.path
elseif remote.scheme ==# 'ssh' && remote.authority !~# ':'
return remote.authority . ':' . remote.path
function! s:ConfigLengthSort(i1, i2) abort
return len(a:i2[0]) - len(a:i1[0])
endfunction
function! s:RemoteCallback(config, into, flags, cb) abort
if a:into.remote_name =~# '^\.\=$'
let a:into.remote_name = s:RemoteDefault(a:config)
endif
let url = a:into.remote_name
if url ==# '.git'
let url = s:GitDir(a:config)
elseif url !~# ':\|^/\|^\a:[\/]\|^\.\.\=/'
let url = FugitiveConfigGet('remote.' . url . '.url', a:config)
endif
let instead_of = []
for [k, vs] in items(fugitive#ConfigGetRegexp('^url\.\zs.\{-\}\ze\.insteadof$', a:config))
for v in vs
call add(instead_of, [v, k])
endfor
endfor
call sort(instead_of, 's:ConfigLengthSort')
for [orig, replacement] in instead_of
if strpart(url, 0, len(orig)) ==# orig
let url = replacement . strpart(url, len(orig))
break
endif
endfor
if index(a:flags, ':noresolve') < 0
call extend(a:into, s:RemoteResolve(url, a:flags))
else
return a:url
call extend(a:into, s:UrlParse(url))
endif
let a:into.user = matchstr(a:into.authority, '.\{-\}\ze@', '', '')
let a:into.host = substitute(a:into.authority, '.\{-\}@', '', '')
let a:into.hostname = substitute(a:into.host, ':\d\+$', '', '')
let a:into.port = matchstr(a:into.host, ':\zs\d\+$', '', '')
if a:into.path =~# '^/'
let a:into.url = a:into.scheme . '://' . a:into.authority . a:into.path
elseif a:into.path =~# '^\~'
let a:into.url = a:into.scheme . '://' . a:into.authority . '/' . a:into.path
elseif a:into.scheme ==# 'ssh' && a:into.authority !~# ':'
let a:into.url = a:into.authority . ':' . a:into.path
else
let a:into.url = url
endif
if len(a:cb)
call call(a:cb[0], [a:into] + a:cb[1:-1])
endif
endfunction
function! s:ConfigLengthSort(i1, i2) abort
return len(a:i2[0]) - len(a:i1[0])
function! s:Remote(dir, remote, flags, cb) abort
let into = {'remote_name': a:remote, 'git_dir': s:GitDir(a:dir)}
let config = fugitive#Config(a:dir, function('s:RemoteCallback'), into, a:flags, a:cb)
if len(a:cb)
return config
else
call fugitive#Wait(config)
return into
endif
endfunction
function! s:RemoteParseArgs(args) abort
@@ -1344,34 +1394,22 @@ function! s:RemoteParseArgs(args) abort
return [dir_or_config, remote, flags, cb]
endfunction
function! fugitive#Remote(...) abort
let [dir_or_config, remote, flags, cb] = s:RemoteParseArgs(a:000)
return s:Remote(dir_or_config, remote, flags, cb)
endfunction
function! s:RemoteUrlCallback(remote, callback) abort
return call(a:callback[0], [a:remote.url] + a:callback[1:-1])
endfunction
function! fugitive#RemoteUrl(...) abort
let [dir_or_config, url, flags, cb] = s:RemoteParseArgs(a:000)
let config = fugitive#Config(dir_or_config)
if url =~# '^\.\=$'
let url = s:RemoteDefault(config)
let [dir_or_config, remote, flags, cb] = s:RemoteParseArgs(a:000)
if len(cb)
let cb = [function('s:RemoteUrlCallback'), cb]
endif
if url ==# '.git'
let url = s:GitDir(config)
elseif url !~# ':\|^/\|^\.\.\=/'
let url = FugitiveConfigGet('remote.' . url . '.url', config)
endif
let instead_of = []
for [k, vs] in items(fugitive#ConfigGetRegexp('^url\.\zs.\{-\}\ze\.insteadof$', config))
for v in vs
call add(instead_of, [v, k])
endfor
endfor
call sort(instead_of, 's:ConfigLengthSort')
for [orig, replacement] in instead_of
if strpart(url, 0, len(orig)) ==# orig
let url = replacement . strpart(url, len(orig))
break
endif
endfor
if index(flags, 1) < 0 && index(flags, get(v:, 'true', 1)) < 0 && index(flags, ':noresolve') < 0
let url = fugitive#ResolveRemote(url)
endif
return url
let remote = s:Remote(dir_or_config, remote, flags, cb)
return get(remote, 'url', remote)
endfunction
" Section: Quickfix
@@ -1410,7 +1448,7 @@ function! s:QuickfixStream(nr, event, title, cmd, first, mods, callback, ...) ab
let opts = {'title': a:title, 'context': {'items': []}}
call s:QuickfixCreate(a:nr, opts)
let event = (a:nr < 0 ? 'c' : 'l') . 'fugitive-' . a:event
silent exe s:DoAutocmd('QuickFixCmdPre ' . event)
exe s:DoAutocmd('QuickFixCmdPre ' . event)
let winnr = winnr()
exe s:QuickfixOpen(a:nr, a:mods)
if winnr != winnr()
@@ -1437,7 +1475,7 @@ function! s:QuickfixStream(nr, event, title, cmd, first, mods, callback, ...) ab
lockvar opts.context.items
call s:QuickfixSet(a:nr, buffer, 'a')
silent exe s:DoAutocmd('QuickFixCmdPost ' . event)
exe s:DoAutocmd('QuickFixCmdPost ' . event)
if a:first && len(s:QuickfixGet(a:nr))
return (a:nr < 0 ? 'cfirst' : 'lfirst')
else
@@ -2449,6 +2487,9 @@ endfunction
augroup fugitive_dummy_events
autocmd!
autocmd User Fugitive* "
autocmd BufWritePre,FileWritePre,FileWritePost * "
autocmd BufNewFile * "
autocmd QuickfixCmdPre,QuickfixCmdPost * "
augroup END
function! s:ReplaceCmd(cmd) abort
@@ -2553,14 +2594,13 @@ let s:rebase_abbrevs = {
function! fugitive#BufReadStatus(...) abort
let amatch = s:Slash(expand('%:p'))
let b:fugitive_type = 'index'
unlet! b:fugitive_reltime
unlet! b:fugitive_reltime b:fugitive_type
try
silent doautocmd BufReadPre
doautocmd BufReadPre
let config = fugitive#Config()
let cmd = [fnamemodify(amatch, ':h')]
setlocal noro ma nomodeline buftype=nowrite
setlocal noreadonly modifiable nomodeline buftype=nowrite
if s:cpath(fnamemodify($GIT_INDEX_FILE !=# '' ? FugitiveVimPath($GIT_INDEX_FILE) : fugitive#Find('.git/index'), ':p')) !=# s:cpath(amatch)
let cmd += [{'env': {'GIT_INDEX_FILE': FugitiveGitPath(amatch)}}]
endif
@@ -2760,7 +2800,7 @@ function! fugitive#BufReadStatus(...) abort
endif
let b:fugitive_diff = diff
if !a:0 && v:cmdbang
if get(a:, 1, v:cmdbang)
unlet! b:fugitive_expanded
endif
let expanded = get(b:, 'fugitive_expanded', {'Staged': {}, 'Unstaged': {}})
@@ -2805,7 +2845,7 @@ function! fugitive#BufReadStatus(...) abort
endif
setlocal nomodified readonly noswapfile
silent doautocmd BufReadPost
doautocmd BufReadPost
setlocal nomodifiable
if &bufhidden ==# ''
setlocal bufhidden=delete
@@ -2849,9 +2889,6 @@ function! fugitive#BufReadStatus(...) abort
call s:Map('x', 'p', ":<C-U>execute <SID>StagePatch(line(\"'<\"),line(\"'>\"))<CR>", '<silent>')
call s:Map('n', 'I', ":<C-U>execute <SID>StagePatch(line('.'),line('.'))<CR>", '<silent>')
call s:Map('x', 'I', ":<C-U>execute <SID>StagePatch(line(\"'<\"),line(\"'>\"))<CR>", '<silent>')
if empty(mapcheck('q', 'n'))
nnoremap <buffer> <silent> q :<C-U>echoerr "fugitive: q is removed in favor of gq (or :q)"<CR>
endif
call s:Map('n', 'gq', ":<C-U>if bufnr('$') == 1<Bar>quit<Bar>else<Bar>bdelete<Bar>endif<CR>", '<silent>')
call s:Map('n', 'R', ":echohl WarningMsg<Bar>echo 'Reloading is automatic. Use :e to force'<Bar>echohl NONE<CR>", '<silent>')
call s:Map('n', 'g<Bar>', ":<C-U>echoerr 'Changed to X'<CR>", '<silent><unique>')
@@ -2878,6 +2915,8 @@ function! fugitive#BufReadStatus(...) abort
return s:DoAutocmd('User FugitiveIndex')
catch /^fugitive:/
return 'echoerr ' . string(v:exception)
finally
let b:fugitive_type = 'index'
endtry
endfunction
@@ -2966,10 +3005,10 @@ function! fugitive#BufReadCmd(...) abort
endif
if rev =~# '^:\d:'
let &l:readonly = !filewritable(fugitive#Find('.git/index', dir))
return 'silent doautocmd BufNewFile'
return 'doautocmd BufNewFile'
else
setlocal readonly nomodifiable
return 'silent doautocmd BufNewFile|echo ' . string(error)
return 'doautocmd BufNewFile|echo ' . string(error)
endif
elseif b:fugitive_type !~# '^\%(tag\|commit\|tree\|blob\)$'
return "echoerr ".string("fugitive: unrecognized git type '".b:fugitive_type."'")
@@ -2994,7 +3033,7 @@ function! fugitive#BufReadCmd(...) abort
if b:fugitive_type !=# 'blob'
setlocal foldmarker=<<<<<<<<,>>>>>>>>
endif
silent exe s:DoAutocmd('BufReadPre')
exe s:DoAutocmd('BufReadPre')
if b:fugitive_type ==# 'tree'
let b:fugitive_display_format = b:fugitive_display_format % 2
if b:fugitive_display_format
@@ -3060,7 +3099,7 @@ function! fugitive#BufReadCmd(...) abort
setlocal modifiable
return 'silent ' . s:DoAutocmd('BufReadPost') .
return s:DoAutocmd('BufReadPost') .
\ (modifiable ? '' : '|setl nomodifiable') . '|' .
\ call('s:DoAutocmd', events)
catch /^fugitive:/
@@ -3162,13 +3201,13 @@ function! s:TempReadPost(file) abort
if dict.filetype ==# 'man' && has('nvim')
let b:man_sect = matchstr(getline(1), '^\w\+(\zs\d\+\ze)')
endif
if !get(g:, 'did_load_ftplugin') && dict.filetype ==# 'fugitiveblame'
call s:BlameMaps(0)
endif
let &l:filetype = dict.filetype
endif
setlocal foldmarker=<<<<<<<<,>>>>>>>>
if !&modifiable
if empty(mapcheck('q', 'n'))
nnoremap <buffer> <silent> q :<C-U>echoerr "fugitive: q is removed in favor of gq (or :q)"<CR>
endif
call s:Map('n', 'gq', ":<C-U>bdelete<CR>", '<silent> <unique>')
endif
endif
@@ -3298,7 +3337,7 @@ function! s:RunReceive(state, tmp, type, job, data, ...) abort
call setbufline(a:state.capture_bufnr, line_count + 1, lines)
endif
call setbufvar(a:state.capture_bufnr, '&modifiable', 0)
if getwinvar(bufwinid(a:state.capture_bufnr), '&previewwindow')
if !a:state.pager && getwinvar(bufwinid(a:state.capture_bufnr), '&previewwindow')
let winnr = bufwinnr(a:state.capture_bufnr)
if winnr > 0
let old_winnr = winnr()
@@ -3677,6 +3716,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
let after_edit = ''
let stream = 0
if a:bang && pager isnot# 2
let state.pager = pager
let pager = 1
let stream = exists('*setbufline')
let do_edit = substitute(s:Mods(a:mods, 'Edge'), '\<tab\>', '-tab', 'g') . 'pedit!'
@@ -4088,7 +4128,7 @@ function! s:DoAutocmdChanged(dir) abort
finally
unlet! g:fugitive_event g:fugitive_result
" Force statusline reload with the buffer's Git dir
let &ro = &ro
let &l:ro = &l:ro
endtry
return ''
endfunction
@@ -4099,7 +4139,7 @@ function! s:ReloadStatusBuffer(...) abort
endif
let original_lnum = a:0 ? a:1 : line('.')
let info = s:StageInfo(original_lnum)
call fugitive#BufReadStatus(1)
call fugitive#BufReadStatus(0)
call setpos('.', [0, s:StageSeek(info, original_lnum), 1, 0])
return ''
endfunction
@@ -4539,8 +4579,8 @@ endfunction
function! s:PreviousItem(count) abort
for i in range(a:count)
if !search(s:item_pattern, 'Wbe') && getline('.') !~# s:item_pattern
call search('^commit ', 'Wbe')
if !search(s:item_pattern, 'Wb') && getline('.') !~# s:item_pattern
call search('^commit ', 'Wb')
endif
endfor
call s:StageReveal()
@@ -5619,7 +5659,7 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, options) abort
\ 'mods': s:Mods(a:mods),
\ 'file': s:Resolve(tempfile)}
let event = listnr < 0 ? 'grep-fugitive' : 'lgrep-fugitive'
silent exe s:DoAutocmd('QuickFixCmdPre ' . event)
exe s:DoAutocmd('QuickFixCmdPre ' . event)
try
if !quiet && &more
let more = 1
@@ -5643,7 +5683,7 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, options) abort
endif
endtry
call s:RunFinished(state)
silent exe s:DoAutocmd('QuickFixCmdPost ' . event)
exe s:DoAutocmd('QuickFixCmdPost ' . event)
if quiet
let bufnr = bufnr('')
exe s:QuickfixOpen(listnr, a:mods)
@@ -5744,7 +5784,7 @@ function! s:LogParse(state, dir, prefix, line) abort
endif
elseif a:state.follow &&
\ a:line =~# '^ \%(mode change \d\|\%(create\|delete\) mode \d\|\%(rename\|copy\|rewrite\) .* (\d\+%)$\)'
let rename = matchstr(a:line, '^ rename \zs.* => .*\ze (\d\+%)$')
let rename = matchstr(a:line, '^ \%(copy\|rename\) \zs.* => .*\ze (\d\+%)$')
if len(rename)
let rename = rename =~# '{.* => .*}' ? rename : '{' . rename . '}'
if a:state.target ==# simplify('/' . substitute(rename, '{.* => \(.*\)}', '\1', ''))
@@ -6139,7 +6179,7 @@ function! fugitive#WriteCommand(line1, line2, range, bang, mods, arg, ...) abort
unlet! restorewinnr
let zero = fugitive#Find(':0:'.file)
silent exe s:DoAutocmd('BufWritePost ' . s:fnameescape(zero))
exe s:DoAutocmd('BufWritePost ' . s:fnameescape(zero))
for tab in range(1,tabpagenr('$'))
for winnr in range(1,tabpagewinnr(tab,'$'))
let bufnr = tabpagebuflist(tab)[winnr-1]
@@ -6731,9 +6771,13 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort
elseif empty(files) && len(matchstr(s:DirCommitFile(@%)[1], '^\x\x\+$'))
let cmd += [matchstr(s:DirCommitFile(@%)[1], '^\x\x\+$')]
elseif empty(files) && !s:HasOpt(flags, '--reverse')
let cmd += ['--contents', tempname . '.in']
silent execute 'noautocmd keepalt %write ' . s:fnameescape(tempname . '.in')
let delete_in = 1
if &modified
let cmd += ['--contents', tempname . '.in']
silent execute 'noautocmd keepalt %write ' . s:fnameescape(tempname . '.in')
let delete_in = 1
elseif &autoread
exe 'checktime ' . bufnr('')
endif
else
call fugitive#Autowrite()
endif
@@ -6943,13 +6987,6 @@ function! s:BlameJump(suffix, ...) abort
let offset = line('.') - line('w0')
let state = s:TempState()
let flags = get(state, 'blame_flags', [])
if a:0 && a:1
if s:HasOpt(flags, '--reverse')
call remove(flags, '--reverse')
else
call add(flags, '--reverse')
endif
endif
let blame_bufnr = s:BlameBufnr()
if blame_bufnr > 0
let bufnr = bufnr('')
@@ -7062,6 +7099,30 @@ function! s:BlameRehighlight() abort
endfor
endfunction
function! s:BlameMaps(is_ftplugin) abort
let ft = a:is_ftplugin
call s:Map('n', '<F1>', ':help :Git_blame<CR>', '<silent>', ft)
call s:Map('n', 'g?', ':help :Git_blame<CR>', '<silent>', ft)
call s:Map('n', 'gq', ':exe <SID>BlameQuit()<CR>', '<silent>', ft)
call s:Map('n', '<2-LeftMouse>', ':<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>', '<silent>', ft)
call s:Map('n', '<CR>', ':<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>', '<silent>', ft)
call s:Map('n', '-', ':<C-U>exe <SID>BlameJump("")<CR>', '<silent>', ft)
call s:Map('n', 's', ':<C-U>exe <SID>BlameJump("")<CR>', '<silent>', ft)
call s:Map('n', 'u', ':<C-U>exe <SID>BlameJump("")<CR>', '<silent>', ft)
call s:Map('n', 'P', ':<C-U>exe <SID>BlameJump("^".v:count1)<CR>', '<silent>', ft)
call s:Map('n', '~', ':<C-U>exe <SID>BlameJump("~".v:count1)<CR>', '<silent>', ft)
call s:Map('n', 'i', ':<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>', '<silent>', ft)
call s:Map('n', 'o', ':<C-U>exe <SID>BlameCommit("split")<CR>', '<silent>', ft)
call s:Map('n', 'O', ':<C-U>exe <SID>BlameCommit("tabedit")<CR>', '<silent>', ft)
call s:Map('n', 'p', ':<C-U>exe <SID>BlameCommit("pedit")<CR>', '<silent>', ft)
call s:Map('n', '.', ":<C-U> <C-R>=substitute(<SID>BlameCommitFileLnum()[0],'^$','@','')<CR><Home>", ft)
call s:Map('n', '(', "-", ft)
call s:Map('n', ')', "+", ft)
call s:Map('n', 'A', ":<C-u>exe 'vertical resize '.(<SID>linechars('.\\{-\\}\\ze [0-9:/+-][0-9:/+ -]* \\d\\+)')+1+v:count)<CR>", '<silent>', ft)
call s:Map('n', 'C', ":<C-u>exe 'vertical resize '.(<SID>linechars('^\\S\\+')+1+v:count)<CR>", '<silent>', ft)
call s:Map('n', 'D', ":<C-u>exe 'vertical resize '.(<SID>linechars('.\\{-\\}\\ze\\d\\ze\\s\\+\\d\\+)')+1-v:count)<CR>", '<silent>', ft)
endfunction
function! fugitive#BlameFileType() abort
setlocal nomodeline
setlocal foldmethod=manual
@@ -7076,29 +7137,7 @@ function! fugitive#BlameFileType() abort
if &modifiable
return ''
endif
call s:Map('n', '<F1>', ':help :Git_blame<CR>', '<silent>')
call s:Map('n', 'g?', ':help :Git_blame<CR>', '<silent>')
if empty(mapcheck('q', 'n'))
nnoremap <buffer> <silent> q :<C-U>echoerr "fugitive: q removed in favor of gq (or :q)"<CR>
endif
call s:Map('n', 'gq', ':exe <SID>BlameQuit()<CR>', '<silent>')
call s:Map('n', '<2-LeftMouse>', ':<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>', '<silent>')
call s:Map('n', '<CR>', ':<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>', '<silent>')
call s:Map('n', '-', ':<C-U>exe <SID>BlameJump("")<CR>', '<silent>')
call s:Map('n', 's', ':<C-U>exe <SID>BlameJump("")<CR>', '<silent>')
call s:Map('n', 'u', ':<C-U>exe <SID>BlameJump("")<CR>', '<silent>')
call s:Map('n', 'P', ':<C-U>exe <SID>BlameJump("^".v:count1)<CR>', '<silent>')
call s:Map('n', '~', ':<C-U>exe <SID>BlameJump("~".v:count1)<CR>', '<silent>')
call s:Map('n', 'i', ':<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>', '<silent>')
call s:Map('n', 'o', ':<C-U>exe <SID>BlameCommit("split")<CR>', '<silent>')
call s:Map('n', 'O', ':<C-U>exe <SID>BlameCommit("tabedit")<CR>', '<silent>')
call s:Map('n', 'p', ':<C-U>exe <SID>BlameCommit("pedit")<CR>', '<silent>')
call s:Map('n', '.', ":<C-U> <C-R>=substitute(<SID>BlameCommitFileLnum()[0],'^$','@','')<CR><Home>")
call s:Map('n', '(', "-")
call s:Map('n', ')', "+")
call s:Map('n', 'A', ":<C-u>exe 'vertical resize '.(<SID>linechars('.\\{-\\}\\ze [0-9:/+-][0-9:/+ -]* \\d\\+)')+1+v:count)<CR>", '<silent>')
call s:Map('n', 'C', ":<C-u>exe 'vertical resize '.(<SID>linechars('^\\S\\+')+1+v:count)<CR>", '<silent>')
call s:Map('n', 'D', ":<C-u>exe 'vertical resize '.(<SID>linechars('.\\{-\\}\\ze\\d\\ze\\s\\+\\d\\+)')+1-v:count)<CR>", '<silent>')
call s:BlameMaps(1)
endfunction
augroup fugitive_blame

View File

@@ -1,6 +1,6 @@
" fugitive.vim - A Git wrapper so awesome, it should be illegal
" Maintainer: Tim Pope <http://tpo.pe/>
" Version: 3.4
" Version: 3.6
" GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim
if exists('g:loaded_fugitive')
@@ -210,6 +210,23 @@ function! FugitiveRemoteUrl(...) abort
return call('fugitive#RemoteUrl', a:000)
endfunction
" FugitiveRemote() returns a data structure parsed from the remote URL.
" For example, for remote URL "https://me@example.com:1234/repo.git", the
" returned dictionary will contain the following:
"
" * "scheme": "https"
" * "authority": "user@example.com:1234"
" * "path": "/repo.git" (for SSH URLs this may be a relative path)
" * "host": "example.com:1234"
" * "hostname": "example.com"
" * "port": "1234"
" * "user": "me"
" * "path": "/repo.git"
" * "url": "https://me@example.com:1234/repo.git"
function! FugitiveRemote(...) abort
return call('fugitive#Remote', a:000)
endfunction
" FugitiveDidChange() triggers a FugitiveChanged event and reloads the summary
" buffer for the current or given buffer number's repository. You can also
" give the result of a FugitiveExecute() and that context will be made
@@ -628,7 +645,7 @@ augroup fugitive
autocmd BufReadCmd index{,.lock}
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
\ let b:git_dir = s:Slash(expand('<amatch>:p:h')) |
\ exe fugitive#BufReadStatus() |
\ exe fugitive#BufReadStatus(v:cmdbang) |
\ elseif filereadable(expand('<amatch>')) |
\ silent doautocmd BufReadPre |
\ keepalt read <amatch> |