From 2cde9172a998eee6294803b04c38b7409c239c4b Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 7 Jul 2019 14:29:37 -0400 Subject: [PATCH] Add section jump maps References https://github.com/tpope/vim-fugitive/issues/1252 --- autoload/fugitive.vim | 22 ++++++++++++++-------- doc/fugitive.txt | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index d8c5ce4..b5b8443 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1683,6 +1683,11 @@ function! fugitive#BufReadStatus() abort exe "xnoremap " nowait "s :execute Do('Stage',1)" exe "nnoremap " nowait "u :execute Do('Unstage',0)" exe "xnoremap " nowait "u :execute Do('Unstage',1)" + nnoremap gu :exe StageJump(v:count, 'Unstaged') + nnoremap gU :exe StageJump(v:count, 'Untracked') + nnoremap gs :exe StageJump(v:count, 'Staged') + nnoremap gp :exe StageJump(v:count, 'Unpushed') + nnoremap gP :exe StageJump(v:count, 'Unpulled') nnoremap C :Gcommit:echohl WarningMsgecho ':Gstatus C is deprecated in favor of cc'echohl NONE nnoremap a :execute Do('Toggle',0) nnoremap i :execute StageIntend(v:count1) @@ -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) diff --git a/doc/fugitive.txt b/doc/fugitive.txt index f7679f8..23a85b3 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -323,6 +323,21 @@ C Open the commit containing the current file. 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 ~