Skip to content

Commit

Permalink
introduce GitGutterGetHunkSummary for statusline integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
bling committed Aug 19, 2013
1 parent 1b5fe1b commit ab58e07
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions plugin/gitgutter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ call s:set('g:gitgutter_diff_args', '')
call s:set('g:gitgutter_escape_grep', 0)

let s:file = ''
let s:hunk_summary = [0, 0, 0]

function! s:init()
if !exists('g:gitgutter_initialised')
Expand Down Expand Up @@ -376,11 +377,25 @@ function! s:find_other_signs(file_name)
endfunction

function! s:show_signs(file_name, modified_lines)
let added = 0
let modified = 0
let removed = 0
for line in a:modified_lines
let line_number = line[0]
let type = 'GitGutterLine' . s:snake_case_to_camel_case(line[1])
call s:add_sign(line_number, type, a:file_name)

if match(line[1], 'added') > -1
let added += 1
endif
if match(line[1], 'modified') > -1
let modified += 1
endif
if match(line[1], 'removed') > -1
let removed += 1
endif
endfor
let s:hunk_summary = [added, modified, removed]
endfunction

function! s:add_sign(line_number, name, file_name)
Expand Down Expand Up @@ -556,6 +571,10 @@ function! GitGutterGetHunks()
return s:is_active() ? s:hunks : []
endfunction

function! GitGutterGetHunkSummary()
return s:hunk_summary
endfunction

nnoremap <silent> <Plug>GitGutterNextHunk :<C-U>execute v:count1 . "GitGutterNextHunk"<CR>
nnoremap <silent> <Plug>GitGutterPrevHunk :<C-U>execute v:count1 . "GitGutterPrevHunk"<CR>
Expand Down

0 comments on commit ab58e07

Please sign in to comment.