airblade / vim-gitgutter

A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.
MIT License
8.35k stars 296 forks source link

integrating vim-gitgutter in lightline #674

Closed mintelm closed 4 years ago

mintelm commented 4 years ago

What is the latest commit SHA in your installed vim-gitgutter? 0946c53cfc6edfb8dbf4b25a27d013c0b6ec6619

What vim/nvim version are you on? nvim 0.4.3

Hi,

I am trying to integrate vim-gitgutter in lightline and I'm having trouble to find the right function to call to show Additions, Deletions and Modified in my statusline.

lightline wiki suggests to integrate other plugins as follows:

let g:lightline = { \ 'colorscheme': 'wombat', \ 'active': { \ 'left': [ [ 'mode', 'paste' ], \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] \ }, \ 'component_function': { \ 'gitbranch': 'fugitive#head' \ }, \ }

Following this, I tried to create a component_function named gitgutterdiff but I am not sure which gitgutter function to call, I have found gitgutter#diff but I don't think it's the right one to call.

Can you help me with this?

polyzen commented 4 years ago

Can't find where I got the initial rendition of this, but: https://gitlab.com/polyzen/dotfiles/blob/dce37955a745ee23efd247306781f8bc4a4d62bc/base/.vim/vimrc#L158

airblade commented 4 years ago

Thanks @polyzen.

The function GitGutterGetHunkSummary() is the one you want to call. I realise now that while it's commented in the code, it's not documented in the README or help file – sorry about that.

Anyway, @polyzen's code works and here is a similar solution modelled on niklaas/lightline-gitdiff.