Show message like "Hunk 4 of 11" after hunk jumping

This commit is contained in:
obcat
2020-11-02 01:44:35 +09:00
committed by Andy Stewart
parent 696a6ed389
commit 987a33355e
4 changed files with 22 additions and 0 deletions

View File

@@ -162,6 +162,12 @@ nmap ]h <Plug>(GitGutterNextHunk)
nmap [h <Plug>(GitGutterPrevHunk) nmap [h <Plug>(GitGutterPrevHunk)
``` ```
When you jump between hunks, a message like `Hunk 4 of 11` is shown on the command line. If you want to turn the message off, you can use:
```viml
let g:gitgutter_show_msg_on_hunk_jumping = 0
```
You can load all your hunks into the quickfix list with `:GitGutterQuickFix`. Note this ignores any unsaved changes in your buffers. If the option `g:gitgutter_use_location_list` is set, this command will load hunks into the current window's location list instead. You can load all your hunks into the quickfix list with `:GitGutterQuickFix`. Note this ignores any unsaved changes in your buffers. If the option `g:gitgutter_use_location_list` is set, this command will load hunks into the current window's location list instead.
You can stage or undo an individual hunk when your cursor is in it: You can stage or undo an individual hunk when your cursor is in it:

View File

@@ -61,6 +61,9 @@ function! gitgutter#hunk#next_hunk(count) abort
let hunk_count += 1 let hunk_count += 1
if hunk_count == a:count if hunk_count == a:count
execute 'normal!' hunk[2] . 'Gzv' execute 'normal!' hunk[2] . 'Gzv'
if g:gitgutter_show_msg_on_hunk_jumping
redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks))
endif
return return
endif endif
endif endif
@@ -86,6 +89,9 @@ function! gitgutter#hunk#prev_hunk(count) abort
if hunk_count == a:count if hunk_count == a:count
let target = hunk[2] == 0 ? 1 : hunk[2] let target = hunk[2] == 0 ? 1 : hunk[2]
execute 'normal!' target . 'Gzv' execute 'normal!' target . 'Gzv'
if g:gitgutter_show_msg_on_hunk_jumping
redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks))
endif
return return
endif endif
endif endif

View File

@@ -308,6 +308,10 @@ Signs:~
|g:gitgutter_sign_modified_removed| |g:gitgutter_sign_modified_removed|
|g:gitgutter_set_sign_backgrounds| |g:gitgutter_set_sign_backgrounds|
Hunk jumping:~
|g:gitgutter_show_msg_on_hunk_jumping|
Hunk previews:~ Hunk previews:~
|g:gitgutter_preview_win_floating| |g:gitgutter_preview_win_floating|
@@ -524,6 +528,11 @@ Default: 0
When switched on, the :GitGutterQuickFix command populates the location list When switched on, the :GitGutterQuickFix command populates the location list
of the current window instead of the global quickfix list. of the current window instead of the global quickfix list.
*g:gitgutter_show_msg_on_hunk_jumping*
Default: 1
When switched on, a message like "Hunk 4 of 11" is shown on hunk jumping.
=============================================================================== ===============================================================================
HIGHLIGHTS *gitgutter-highlights* HIGHLIGHTS *gitgutter-highlights*

View File

@@ -76,6 +76,7 @@ call s:set('g:gitgutter_async', 1)
call s:set('g:gitgutter_log', 0) call s:set('g:gitgutter_log', 0)
call s:set('g:gitgutter_use_location_list', 0) call s:set('g:gitgutter_use_location_list', 0)
call s:set('g:gitgutter_close_preview_on_escape', 0) call s:set('g:gitgutter_close_preview_on_escape', 0)
call s:set('g:gitgutter_show_msg_on_hunk_jumping', 1)
call s:set('g:gitgutter_git_executable', 'git') call s:set('g:gitgutter_git_executable', 'git')
if !executable(g:gitgutter_git_executable) if !executable(g:gitgutter_git_executable)