From 9add23a492cba86df506db3be363c699f6c8d28e Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Wed, 15 Jan 2020 11:50:47 +0000 Subject: [PATCH] Document how to get diff stats in statusline Closes #674. --- README.mkd | 14 ++++++++++++++ doc/gitgutter.txt | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/README.mkd b/README.mkd index 4f8495c..0c21f3c 100644 --- a/README.mkd +++ b/README.mkd @@ -234,6 +234,20 @@ gitgutter#fold#foldtext(): +-- 45 lines (*): abcdef You can use `gitgutter#fold#is_changed()` in your own `foldtext` expression to find out whether the folded lines have been changed. +### Status line + +Call the `GitGutterGetHunkSummary()` function from your status line to get a list of counts of added, modified, and removed lines in the current buffer. For example: + +```viml +" Your vimrc +function! GitStatus() + let [a,m,r] = GitGutterGetHunkSummary() + return printf('+%d ~%d -%d', a, m, r) +endfunction +set statusline+=%{GitStatus()} +``` + + ### Customisation You can customise: diff --git a/doc/gitgutter.txt b/doc/gitgutter.txt index f3c09b8..1f52989 100644 --- a/doc/gitgutter.txt +++ b/doc/gitgutter.txt @@ -17,6 +17,7 @@ CONTENTS *gitgutter* Commands ..................... |gitgutter-commands| Mappings ..................... |gitgutter-mappings| Autocommand .................. |gitgutter-autocommand| + Status line .................. |gitgutter-statusline| Options ...................... |gitgutter-options| Highlights ................... |gitgutter-highlights| FAQ .......................... |gitgutter-faq| @@ -244,6 +245,23 @@ trailing empty lines. < +=============================================================================== +STATUS LINE *gitgutter-statusline* + + +Call the `GitGutterGetHunkSummary()` function from your status line to get a +list of counts of added, modified, and removed lines in the current buffer. +For example: +> + " Your vimrc + function! GitStatus() + let [a,m,r] = GitGutterGetHunkSummary() + return printf('+%d ~%d -%d', a, m, r) + endfunction + set statusline+=%{GitStatus()} +< + + =============================================================================== OPTIONS *gitgutter-options*