1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 02:50:06 +08:00

Add hunks summary

This commit is contained in:
wsdjeg 2017-12-01 10:58:30 +08:00
parent d81c440947
commit e6c4ae5d02
2 changed files with 23 additions and 1 deletions

View File

@ -195,7 +195,7 @@ let g:spacevim_statusline_inactive_separator = 'arrow'
" \ 'version control info'
" \ ]
" <
let g:spacevim_statusline_left_sections = ['winnr', 'filename', 'major mode', 'syntax checking', 'minor mode lighters', 'version control info']
let g:spacevim_statusline_left_sections = ['winnr', 'filename', 'major mode', 'syntax checking', 'minor mode lighters', 'version control info', 'hunks']
""
" Define the right section of statusline in active windows. By default:
" >

View File

@ -222,6 +222,25 @@ else
endfunction
endif
function! s:hunks() abort
let hunks = [0,0,0]
try
let hunks = GitGutterGetHunkSummary()
catch
endtry
let rst = ''
if hunks[0] > 0
let rst .= hunks[0] . '+ '
endif
if hunks[1] > 0
let rst .= hunks[1] . '~ '
endif
if hunks[2] > 0
let rst .= hunks[2] . '- '
endif
return empty(rst) ? '' : ' ' . rst
endfunction
let s:registed_sections = {
\ 'winnr' : function('s:winnr'),
\ 'syntax checking' : function('s:syntax_checking'),
@ -230,6 +249,7 @@ let s:registed_sections = {
\ 'major mode' : function('s:major_mode'),
\ 'minor mode lighters' : function('s:modes'),
\ 'version control info' : function('s:git_branch'),
\ 'hunks' : function('s:hunks'),
\ 'cursorpos' : function('s:cursorpos'),
\ 'percentage' : function('s:percentage'),
\ 'time' : function('s:time'),
@ -474,6 +494,8 @@ function! SpaceVim#layers#core#statusline#config() abort
\ 'toggle the cursor position', 1)
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'T'], 'if &laststatus == 2 | let &laststatus = 0 | else | let &laststatus = 2 | endif',
\ 'toggle the statuline itself', 1)
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'h'], 'call SpaceVim#layers#core#statusline#toggle_section("hunks")',
\ 'toggle the hunks summary', 1)
function! TagbarStatusline(...) abort
let name = (strwidth(a:3) > (g:spacevim_sidebar_width - 15)) ? a:3[:g:spacevim_sidebar_width - 20] . '..' : a:3
return s:STATUSLINE.build([s:winnr(),' Tagbar ', ' ' . name . ' '], [], s:lsep, s:rsep, '',