motiejus/dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.jakstys.lt/motiejus/dotfiles.git
Log | Tree | Refs | README | LICENSE

commit ebd7c9ddd35ee1ed6c8f2b3fa60c98f6b2a49923 (tree)
parent 45fd3f4cb871a0edf582119f2db3e7d617dffb4f
Author: Tim Pope <code@tpope.net>
Date:   Mon,  8 Jul 2019 14:41:59 -0400

Add next/previous section maps

Diffstat:
Mautoload/fugitive.vim | 25+++++++++++++++++++++++++
Mdoc/fugitive.txt | 18++++++++++++------
2 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim @@ -1730,6 +1730,8 @@ function! fugitive#BufReadStatus() abort nunmap <buffer> ~ nnoremap <buffer> <silent> <C-N> :<C-U>execute <SID>StageNext(v:count1)<CR> nnoremap <buffer> <silent> <C-P> :<C-U>execute <SID>StagePrevious(v:count1)<CR> + nnoremap <buffer> <silent> [[ :<C-U>execute <SID>PreviousSection(v:count1)<CR> + nnoremap <buffer> <silent> ]] :<C-U>execute <SID>NextSection(v:count1)<CR> exe "nnoremap <buffer> <silent>" nowait "- :<C-U>execute <SID>Do('Toggle',0)<CR>" exe "xnoremap <buffer> <silent>" nowait "- :<C-U>execute <SID>Do('Toggle',1)<CR>" exe "nnoremap <buffer> <silent>" nowait "s :<C-U>execute <SID>Do('Stage',0)<CR>" @@ -2565,6 +2567,29 @@ function! s:StagePrevious(count) abort endif endfunction +function! s:NextSection(count) abort + for i in range(a:count) + if !search('^[A-Z][a-z][^:]*$','W') + return '.' + endif + + + endfor + call s:StageReveal() + return '.' +endfunction + +function! s:PreviousSection(count) abort + - + for i in range(a:count) + if !search('^[A-Z][a-z][^:]*$\|\%^','bW') || line('.') == 1 + return '.' + endif + + + endfor + call s:StageReveal() + return '.' +endfunction + function! s:StageInline(mode, ...) abort let lnum1 = a:0 ? a:1 : line('.') let lnum = lnum1 + 1 diff --git a/doc/fugitive.txt b/doc/fugitive.txt @@ -249,12 +249,6 @@ u Unstage (reset) the file or hunk under the cursor. *fugitive_-* - Stage or unstage the file or hunk under the cursor. - *fugitive_CTRL-N* -<C-N> Skip to the next file or hunk. - - *fugitive_CTRL-P* -<C-P> Skip to the previous file or hunk. - *fugitive_X* X Discard the change under the cursor. This uses `checkout` or `clean` under the hood. A command is @@ -327,6 +321,18 @@ C Open the commit containing the current file. <C-W>C Open the commit containing the current file in a new split. + *fugitive_CTRL-P* +<C-P> Jump to the previous file or hunk. + + *fugitive_CTRL-N* +<C-N> Jump to the next file or hunk. + + *fugitive_[[* +[[ Jump to the previous section. + + *fugitive_]]* +]] Jump to the next section. + *fugitive_gu* gu Jump to "Unstaged" section.