mirror of
https://github.com/vim-airline/vim-airline.git
synced 2026-03-01 21:06:50 +08:00
introduce parts metadata.
This commit is contained in:
@@ -1,39 +1,12 @@
|
||||
" MIT License. Copyright (c) 2013 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
function! s:get_val(part, append)
|
||||
if has_key(g:airline_parts, a:part)
|
||||
let val = g:airline_parts[a:part]
|
||||
if match(val, '%\| ') > -1
|
||||
return val
|
||||
elseif a:append > 0
|
||||
return '%{airline#parts#append("'.val.'")}'
|
||||
elseif a:append < 0
|
||||
return '%{airline#parts#prepend("'.val.'")}'
|
||||
else
|
||||
return '%{'.val.'()}'
|
||||
endif
|
||||
endif
|
||||
return a:part
|
||||
function! airline#util#append(text)
|
||||
return empty(a:text) ? '' : ' '.g:airline_left_alt_sep.' '.a:text
|
||||
endfunction
|
||||
|
||||
function! airline#util#define_left_section(key, parts)
|
||||
if !exists('g:airline_section_{a:key}') && len(a:parts) > 0
|
||||
let g:airline_section_{a:key} = s:get_val(a:parts[0], 0)
|
||||
for i in range(1, len(a:parts) - 1)
|
||||
let g:airline_section_{a:key} .= s:get_val(a:parts[i], 1)
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#util#define_right_section(key, parts)
|
||||
if !exists('g:airline_section_{a:key}') && len(a:parts) > 0
|
||||
let g:airline_section_{a:key} = ''
|
||||
for i in range(0, len(a:parts) - 2)
|
||||
let g:airline_section_{a:key} .= s:get_val(a:parts[i], -1)
|
||||
endfor
|
||||
let g:airline_section_{a:key} .= s:get_val(a:parts[-1], 0)
|
||||
endif
|
||||
function! airline#util#prepend(text)
|
||||
return empty(a:text) ? '' : a:text.' '.g:airline_right_alt_sep.' '
|
||||
endfunction
|
||||
|
||||
if v:version >= 704
|
||||
|
||||
Reference in New Issue
Block a user