mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-29 20:23:39 +08:00
introduce fragments variable to store all possible parts.
This commit is contained in:
parent
d5d87d2cdc
commit
83a1d7e47c
|
@ -1,18 +1,18 @@
|
||||||
" MIT License. Copyright (c) 2013 Bailey Ling.
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
||||||
" vim: et ts=2 sts=2 sw=2
|
" vim: et ts=2 sts=2 sw=2
|
||||||
|
|
||||||
function! airline#fragments#get_paste()
|
function! airline#fragments#paste()
|
||||||
return g:airline_detect_paste && &paste ? ' '.g:airline_symbols.paste : ''
|
return g:airline_detect_paste && &paste ? ' '.g:airline_symbols.paste : ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#fragments#get_iminsert()
|
function! airline#fragments#iminsert()
|
||||||
if g:airline_detect_iminsert && &iminsert && exists('b:keymap_name')
|
if g:airline_detect_iminsert && &iminsert && exists('b:keymap_name')
|
||||||
return ' '.g:airline_left_alt_sep.' '.toupper(b:keymap_name)
|
return ' '.g:airline_left_alt_sep.' '.toupper(b:keymap_name)
|
||||||
endif
|
endif
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#fragments#get_readonly()
|
function! airline#fragments#readonly()
|
||||||
return &readonly ? g:airline_symbols.readonly : ''
|
return &readonly ? g:airline_symbols.readonly : ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,16 @@ call extend(g:airline_symbols, {
|
||||||
\ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ''),
|
\ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ''),
|
||||||
\ }, 'keep')
|
\ }, 'keep')
|
||||||
|
|
||||||
call s:check_defined('g:airline_mode_map', {
|
call s:check_defined('g:airline_fragments', {})
|
||||||
|
call extend(g:airline_fragments, {
|
||||||
|
\ 'mode': '%{get(w:,"airline_current_mode","")}',
|
||||||
|
\ 'iminsert': '%{airline#fragments#iminsert()}',
|
||||||
|
\ 'paste': '%{airline#fragments#paste()}',
|
||||||
|
\ 'readonly': '%{airline#fragments#readonly()}',
|
||||||
|
\ }, 'keep')
|
||||||
|
|
||||||
|
call s:check_defined('g:airline_mode_map', {})
|
||||||
|
call extend(g:airline_mode_map, {
|
||||||
\ '__' : '------',
|
\ '__' : '------',
|
||||||
\ 'n' : 'NORMAL',
|
\ 'n' : 'NORMAL',
|
||||||
\ 'i' : 'INSERT',
|
\ 'i' : 'INSERT',
|
||||||
|
@ -49,19 +58,20 @@ call s:check_defined('g:airline_mode_map', {
|
||||||
\ 's' : 'SELECT',
|
\ 's' : 'SELECT',
|
||||||
\ 'S' : 'S-LINE',
|
\ 'S' : 'S-LINE',
|
||||||
\ '' : 'S-BLOCK',
|
\ '' : 'S-BLOCK',
|
||||||
\ })
|
\ }, 'keep')
|
||||||
|
|
||||||
call s:check_defined('g:airline_theme_map', {
|
call s:check_defined('g:airline_theme_map', {})
|
||||||
|
call extend(g:airline_theme_map, {
|
||||||
\ 'Tomorrow.*': 'tomorrow',
|
\ 'Tomorrow.*': 'tomorrow',
|
||||||
\ 'mo[l|n]okai': 'molokai',
|
\ 'mo[l|n]okai': 'molokai',
|
||||||
\ 'wombat.*': 'wombat',
|
\ 'wombat.*': 'wombat',
|
||||||
\ '.*solarized.*': 'solarized',
|
\ '.*solarized.*': 'solarized',
|
||||||
\ })
|
\ }, 'keep')
|
||||||
|
|
||||||
call s:check_defined('g:airline_section_a', '%{get(w:,"airline_current_mode","")}%{airline#fragments#get_paste()}%{airline#fragments#get_iminsert()}')
|
call s:check_defined('g:airline_section_a', (g:airline_fragments.mode).(g:airline_fragments.paste).(g:airline_fragments.iminsert))
|
||||||
call s:check_defined('g:airline_section_b', '')
|
call s:check_defined('g:airline_section_b', '')
|
||||||
call s:check_defined('g:airline_section_c', '%f%m')
|
call s:check_defined('g:airline_section_c', '%f%m')
|
||||||
call s:check_defined('g:airline_section_gutter', '%#airline_file#%{airline#fragments#get_readonly()}%=')
|
call s:check_defined('g:airline_section_gutter', '%#airline_file#'.(g:airline_fragments.readonly).'%=')
|
||||||
call s:check_defined('g:airline_section_x', "%{strlen(&filetype)>0?&filetype:''}")
|
call s:check_defined('g:airline_section_x', "%{strlen(&filetype)>0?&filetype:''}")
|
||||||
call s:check_defined('g:airline_section_y', "%{strlen(&fenc)>0?&fenc:''}%{strlen(&ff)>0?'['.&ff.']':''}")
|
call s:check_defined('g:airline_section_y', "%{strlen(&fenc)>0?&fenc:''}%{strlen(&ff)>0?'['.&ff.']':''}")
|
||||||
call s:check_defined('g:airline_section_z', '%3p%% %{g:airline_symbols.linenr} %3l:%3c')
|
call s:check_defined('g:airline_section_z', '%3p%% %{g:airline_symbols.linenr} %3l:%3c')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user