From 987a33355ef424161fdbc4e5d625b5b5aed9704c Mon Sep 17 00:00:00 2001 From: obcat Date: Mon, 2 Nov 2020 01:44:35 +0900 Subject: [PATCH] Show message like "Hunk 4 of 11" after hunk jumping --- README.mkd | 6 ++++++ autoload/gitgutter/hunk.vim | 6 ++++++ doc/gitgutter.txt | 9 +++++++++ plugin/gitgutter.vim | 1 + 4 files changed, 22 insertions(+) diff --git a/README.mkd b/README.mkd index 6a340a5..c8dc9aa 100644 --- a/README.mkd +++ b/README.mkd @@ -162,6 +162,12 @@ nmap ]h (GitGutterNextHunk) nmap [h (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 stage or undo an individual hunk when your cursor is in it: diff --git a/autoload/gitgutter/hunk.vim b/autoload/gitgutter/hunk.vim index 7d4b6e1..9d18d92 100644 --- a/autoload/gitgutter/hunk.vim +++ b/autoload/gitgutter/hunk.vim @@ -61,6 +61,9 @@ function! gitgutter#hunk#next_hunk(count) abort let hunk_count += 1 if hunk_count == a:count 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 endif endif @@ -86,6 +89,9 @@ function! gitgutter#hunk#prev_hunk(count) abort if hunk_count == a:count let target = hunk[2] == 0 ? 1 : hunk[2] 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 endif endif diff --git a/doc/gitgutter.txt b/doc/gitgutter.txt index 546ecd5..72da3df 100644 --- a/doc/gitgutter.txt +++ b/doc/gitgutter.txt @@ -308,6 +308,10 @@ Signs:~ |g:gitgutter_sign_modified_removed| |g:gitgutter_set_sign_backgrounds| +Hunk jumping:~ + + |g:gitgutter_show_msg_on_hunk_jumping| + Hunk previews:~ |g:gitgutter_preview_win_floating| @@ -524,6 +528,11 @@ Default: 0 When switched on, the :GitGutterQuickFix command populates the location 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* diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index 1174c44..431d322 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -76,6 +76,7 @@ call s:set('g:gitgutter_async', 1) call s:set('g:gitgutter_log', 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_show_msg_on_hunk_jumping', 1) call s:set('g:gitgutter_git_executable', 'git') if !executable(g:gitgutter_git_executable)