Add section jump maps

References https://github.com/tpope/vim-fugitive/issues/1252
This commit is contained in:
Tim Pope 2019-07-07 14:29:37 -04:00
parent e0d4a281a8
commit 2cde9172a9
2 changed files with 29 additions and 8 deletions

View File

@ -1683,6 +1683,11 @@ function! fugitive#BufReadStatus() abort
exe "xnoremap <buffer> <silent>" nowait "s :<C-U>execute <SID>Do('Stage',1)<CR>"
exe "nnoremap <buffer> <silent>" nowait "u :<C-U>execute <SID>Do('Unstage',0)<CR>"
exe "xnoremap <buffer> <silent>" nowait "u :<C-U>execute <SID>Do('Unstage',1)<CR>"
nnoremap <buffer> <silent> gu :<C-U>exe <SID>StageJump(v:count, 'Unstaged')<CR>
nnoremap <buffer> <silent> gU :<C-U>exe <SID>StageJump(v:count, 'Untracked')<CR>
nnoremap <buffer> <silent> gs :<C-U>exe <SID>StageJump(v:count, 'Staged')<CR>
nnoremap <buffer> <silent> gp :<C-U>exe <SID>StageJump(v:count, 'Unpushed')<CR>
nnoremap <buffer> <silent> gP :<C-U>exe <SID>StageJump(v:count, 'Unpulled')<CR>
nnoremap <buffer> <silent> C :<C-U>Gcommit<CR>:echohl WarningMsg<Bar>echo ':Gstatus C is deprecated in favor of cc'<Bar>echohl NONE<CR>
nnoremap <buffer> <silent> a :<C-U>execute <SID>Do('Toggle',0)<CR>
nnoremap <buffer> <silent> i :<C-U>execute <SID>StageIntend(v:count1)<CR>
@ -2080,6 +2085,15 @@ function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args
return ''
endfunction
function! s:StageJump(offset, section, ...) abort
let line = search('^' . a:section, 'nw')
if line
exe line
return s:StageNext(a:offset ? a:offset : 1)
endif
return ''
endfunction
function! s:StageSeek(info, fallback) abort
let info = a:info
if empty(info.section)
@ -2709,14 +2723,6 @@ function! s:DoToggleHeadHeader(value) abort
call search('\C^index$', 'wc')
endfunction
function! s:DoStageHeadHeader(value) abort
exe search('^Untracked\|^Unstaged', 'wn') + 1
endfunction
function! s:DoUnstageHeadHeader(value) abort
exe search('^Staged', 'wn') + 1
endfunction
function! s:DoToggleUnpushedHeading(heading) abort
let remote = matchstr(a:heading, 'to \zs[^/]\+\ze/')
if empty(remote)

View File

@ -323,6 +323,21 @@ C Open the commit containing the current file.
<C-W>C Open the commit containing the current file in a new
split.
*fugitive_gu*
gu Jump to "Unstaged" section.
*fugitive_gU*
gU Jump to "Untracked" section.
*fugitive_gs*
gs Jump to "Staged" section.
*fugitive_gp*
gp Jump to "Unpushed" section.
*fugitive_gP*
gP Jump to "Unpulled" section.
*fugitive_c*
Commit mappings ~