From 3599736179761c5ba38b0de7774d56b53f4485ab Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Thu, 23 Apr 2020 08:59:26 +0100 Subject: [PATCH] Fire GitGutterStage User event after staging Closes #698. --- README.mkd | 4 ++++ autoload/gitgutter/hunk.vim | 5 +++++ doc/gitgutter.txt | 6 +++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.mkd b/README.mkd index bb39d14..3169e2d 100644 --- a/README.mkd +++ b/README.mkd @@ -88,6 +88,10 @@ You can jump between hunks with `[c` and `]c`. You can preview, stage, and undo You cannot unstage a staged hunk. +After updating the signs, the plugin fires the `GitGutter` User autocommand. + +After staging a hunk or part of a hunk, the plugin fires the `GitGutterStage` User autocommand. + #### Activation diff --git a/autoload/gitgutter/hunk.vim b/autoload/gitgutter/hunk.vim index 4f0f7c7..0723bc5 100644 --- a/autoload/gitgutter/hunk.vim +++ b/autoload/gitgutter/hunk.vim @@ -1,4 +1,5 @@ let s:winid = 0 +let s:nomodeline = (v:version > 703 || (v:version == 703 && has('patch442'))) ? '' : '' function! gitgutter#hunk#set_hunks(bufnr, hunks) abort call gitgutter#utility#setbufvar(a:bufnr, 'hunks', a:hunks) @@ -274,6 +275,10 @@ function! s:stage(hunk_diff) \ diff) if v:shell_error call gitgutter#utility#warn('patch does not apply') + else + if exists('#User#GitGutterStage') + execute 'doautocmd' s:nomodeline 'User GitGutterStage' + endif endif " Refresh gitgutter's view of buffer. diff --git a/doc/gitgutter.txt b/doc/gitgutter.txt index 074f334..1eb3fea 100644 --- a/doc/gitgutter.txt +++ b/doc/gitgutter.txt @@ -177,7 +177,7 @@ Commands for folds:~ =============================================================================== -AUTOCOMMAND *gitgutter-autocommand* +AUTOCOMMANDS *gitgutter-autocommands* User GitGutter~ @@ -189,6 +189,10 @@ event GitGutter. You can listen for this event, for example: A dictionary `g:gitgutter_hook_context` is made available during its execution, which contains an entry `bufnr` that contains the buffer number being updated. +User GitGutterStage~ + +After staging a hunk or part of a hunk vim-gitgutter fires a |User| |autocmd| +with the event GitGutterStage. Staging always happens in the current buffer. =============================================================================== MAPPINGS *gitgutter-mappings*