mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 19:43:47 -05:00
introduce GitGutterGetHunkSummary for statusline integration.
This commit is contained in:
@@ -30,6 +30,7 @@ call s:set('g:gitgutter_diff_args', '')
|
|||||||
call s:set('g:gitgutter_escape_grep', 0)
|
call s:set('g:gitgutter_escape_grep', 0)
|
||||||
|
|
||||||
let s:file = ''
|
let s:file = ''
|
||||||
|
let s:hunk_summary = [0, 0, 0]
|
||||||
|
|
||||||
function! s:init()
|
function! s:init()
|
||||||
if !exists('g:gitgutter_initialised')
|
if !exists('g:gitgutter_initialised')
|
||||||
@@ -376,11 +377,25 @@ function! s:find_other_signs(file_name)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:show_signs(file_name, modified_lines)
|
function! s:show_signs(file_name, modified_lines)
|
||||||
|
let added = 0
|
||||||
|
let modified = 0
|
||||||
|
let removed = 0
|
||||||
for line in a:modified_lines
|
for line in a:modified_lines
|
||||||
let line_number = line[0]
|
let line_number = line[0]
|
||||||
let type = 'GitGutterLine' . s:snake_case_to_camel_case(line[1])
|
let type = 'GitGutterLine' . s:snake_case_to_camel_case(line[1])
|
||||||
call s:add_sign(line_number, type, a:file_name)
|
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
|
endfor
|
||||||
|
let s:hunk_summary = [added, modified, removed]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:add_sign(line_number, name, file_name)
|
function! s:add_sign(line_number, name, file_name)
|
||||||
@@ -556,6 +571,10 @@ function! GitGutterGetHunks()
|
|||||||
return s:is_active() ? s:hunks : []
|
return s:is_active() ? s:hunks : []
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! GitGutterGetHunkSummary()
|
||||||
|
return s:hunk_summary
|
||||||
|
endfunction
|
||||||
|
|
||||||
nnoremap <silent> <Plug>GitGutterNextHunk :<C-U>execute v:count1 . "GitGutterNextHunk"<CR>
|
nnoremap <silent> <Plug>GitGutterNextHunk :<C-U>execute v:count1 . "GitGutterNextHunk"<CR>
|
||||||
nnoremap <silent> <Plug>GitGutterPrevHunk :<C-U>execute v:count1 . "GitGutterPrevHunk"<CR>
|
nnoremap <silent> <Plug>GitGutterPrevHunk :<C-U>execute v:count1 . "GitGutterPrevHunk"<CR>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user