Skip to content

Add 'g:lightline#gitdiff#show_empty_indicators' option #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ provide your own. Take a look at the source of both functions for inspiration
or consult me if you need help. I am happy to bundle additional faster and more
feature-rich algorithms in the package.

You can show empty indicators (i.e. `A: 0 D: 0 M: 0`) in the following way:
```vim
let g:lightline#gitdiff#show_empty_indicators = 1
```

# How it works / performance

In the background, `lightline#gitdiff#get()` calls `git --numstat` or `git
Expand Down
7 changes: 4 additions & 3 deletions autoload/lightline/gitdiff/algorithms/word_diff_porcelain.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ function! lightline#gitdiff#algorithms#word_diff_porcelain#calculate(buffer) abo
let l:lines_modified = len(filter(copy(l:changes), { idx, val -> val ==# 'M' }))

let l:ret = {}
let l:show_empty_indicators = exists('g:lightline#gitdiff#show_empty_indicators') && g:lightline#gitdiff#show_empty_indicators

if l:lines_added > 0
if l:lines_added > 0 || l:show_empty_indicators
let l:ret['A'] = l:lines_added
endif

if l:lines_deleted > 0
if l:lines_deleted > 0 || l:show_empty_indicators
let l:ret['D'] = l:lines_deleted
endif

if l:lines_modified > 0
if l:lines_modified > 0 || l:show_empty_indicators
let l:ret['M'] = l:lines_modified
endif

Expand Down