mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-25 23:14:50 +02:00
Merge pull request #1877 from maxnordlund/resepct-minwidth-for-vcs
Respect minwidth for hunks and branch parts
This commit is contained in:
commit
eb0ddf61dc
@ -266,13 +266,14 @@ function! airline#extensions#branch#head()
|
||||
endif
|
||||
endif
|
||||
|
||||
let minwidth = empty(get(b:, 'airline_hunks', '')) ? 14 : 7
|
||||
let b:airline_head = airline#util#shorten(b:airline_head, 120, minwidth)
|
||||
return b:airline_head
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#branch#get_head()
|
||||
let head = airline#extensions#branch#head()
|
||||
let winwidth = get(airline#parts#get('branch'), 'minwidth', 120)
|
||||
let minwidth = empty(get(b:, 'airline_hunks', '')) ? 14 : 7
|
||||
let head = airline#util#shorten(head, winwidth, minwidth)
|
||||
let empty_message = get(g:, 'airline#extensions#branch#empty_message', '')
|
||||
let symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch)
|
||||
return empty(head)
|
||||
|
@ -42,7 +42,7 @@ function! s:get_hunks_empty()
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:get_hunks()
|
||||
function! airline#extensions#hunks#get_raw_hunks()
|
||||
if !exists('b:source_func') || get(b:, 'source_func', '') is# 's:get_hunks_empty'
|
||||
if get(g:, 'loaded_signify') && sy#buffer_is_active()
|
||||
let b:source_func = 's:get_hunks_signify'
|
||||
@ -73,11 +73,12 @@ function! airline#extensions#hunks#get_hunks()
|
||||
\ get(b:, 'source_func', '') isnot# 's:get_hunks_changes'
|
||||
return b:airline_hunks
|
||||
endif
|
||||
let hunks = s:get_hunks()
|
||||
let hunks = airline#extensions#hunks#get_raw_hunks()
|
||||
let string = ''
|
||||
let winwidth = get(airline#parts#get('hunks'), 'minwidth', 100)
|
||||
if !empty(hunks)
|
||||
for i in [0, 1, 2]
|
||||
if (s:non_zero_only == 0 && airline#util#winwidth() > 100) || hunks[i] > 0
|
||||
if (s:non_zero_only == 0 && airline#util#winwidth() > winwidth) || hunks[i] > 0
|
||||
let string .= printf('%s%s ', s:hunk_symbols[i], hunks[i])
|
||||
endif
|
||||
endfor
|
||||
|
@ -151,8 +151,14 @@ function! airline#init#bootstrap()
|
||||
\ 'raw': '/%L%{g:airline_symbols.maxlinenr}',
|
||||
\ 'accent': 'bold'})
|
||||
call airline#parts#define_function('ffenc', 'airline#parts#ffenc')
|
||||
call airline#parts#define_empty(['hunks', 'branch', 'obsession', 'tagbar',
|
||||
\ 'syntastic-warn', 'syntastic-err', 'eclim', 'whitespace','windowswap',
|
||||
call airline#parts#define('hunks', {
|
||||
\ 'raw': '',
|
||||
\ 'minwidth': 100})
|
||||
call airline#parts#define('branch', {
|
||||
\ 'raw': '',
|
||||
\ 'minwidth': 120})
|
||||
call airline#parts#define_empty(['obsession', 'tagbar', 'syntastic-warn',
|
||||
\ 'syntastic-err', 'eclim', 'whitespace','windowswap',
|
||||
\ 'ycm_error_count', 'ycm_warning_count', 'neomake_error_count',
|
||||
\ 'neomake_warning_count', 'ale_error_count', 'ale_warning_count',
|
||||
\ 'languageclient_error_count', 'languageclient_warning_count'])
|
||||
|
@ -632,6 +632,10 @@ vim-signify <https://github.com/mhinz/vim-signify>
|
||||
changesPlugin <https://github.com/chrisbra/changesPlugin>
|
||||
quickfixsigns <https://github.com/tomtom/quickfixsigns_vim>
|
||||
|
||||
You can use `airline#extensions#hunks#get_raw_hunks()` to get the full hunks,
|
||||
without shortening. This allows for advanced customization, or a quick way of
|
||||
querying how many changes you got. It will return something like '+4 ~2 -1'.
|
||||
|
||||
* enable/disable showing a summary of changed hunks under source control. >
|
||||
let g:airline#extensions#hunks#enabled = 1
|
||||
<
|
||||
|
Loading…
x
Reference in New Issue
Block a user