mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-23 01:09:56 +08:00
Add hunks summary
This commit is contained in:
parent
d81c440947
commit
e6c4ae5d02
@ -195,7 +195,7 @@ let g:spacevim_statusline_inactive_separator = 'arrow'
|
|||||||
" \ 'version control info'
|
" \ '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:
|
" Define the right section of statusline in active windows. By default:
|
||||||
" >
|
" >
|
||||||
|
@ -222,6 +222,25 @@ else
|
|||||||
endfunction
|
endfunction
|
||||||
endif
|
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 = {
|
let s:registed_sections = {
|
||||||
\ 'winnr' : function('s:winnr'),
|
\ 'winnr' : function('s:winnr'),
|
||||||
\ 'syntax checking' : function('s:syntax_checking'),
|
\ 'syntax checking' : function('s:syntax_checking'),
|
||||||
@ -230,6 +249,7 @@ let s:registed_sections = {
|
|||||||
\ 'major mode' : function('s:major_mode'),
|
\ 'major mode' : function('s:major_mode'),
|
||||||
\ 'minor mode lighters' : function('s:modes'),
|
\ 'minor mode lighters' : function('s:modes'),
|
||||||
\ 'version control info' : function('s:git_branch'),
|
\ 'version control info' : function('s:git_branch'),
|
||||||
|
\ 'hunks' : function('s:hunks'),
|
||||||
\ 'cursorpos' : function('s:cursorpos'),
|
\ 'cursorpos' : function('s:cursorpos'),
|
||||||
\ 'percentage' : function('s:percentage'),
|
\ 'percentage' : function('s:percentage'),
|
||||||
\ 'time' : function('s:time'),
|
\ 'time' : function('s:time'),
|
||||||
@ -474,6 +494,8 @@ function! SpaceVim#layers#core#statusline#config() abort
|
|||||||
\ 'toggle the cursor position', 1)
|
\ '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',
|
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)
|
\ '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
|
function! TagbarStatusline(...) abort
|
||||||
let name = (strwidth(a:3) > (g:spacevim_sidebar_width - 15)) ? a:3[:g:spacevim_sidebar_width - 20] . '..' : a:3
|
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, '',
|
return s:STATUSLINE.build([s:winnr(),' Tagbar ', ' ' . name . ' '], [], s:lsep, s:rsep, '',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user