powerline font symbol support

This commit is contained in:
Bailey Ling 2013-06-30 23:10:11 +02:00
parent a979c9bf52
commit b3e48b942f
2 changed files with 14 additions and 10 deletions

View File

@ -24,10 +24,11 @@ there are a couple configuration values available:
* `g:airline_right_sep` the seperator used on the right side * `g:airline_right_sep` the seperator used on the right side
* `g:airline_enable_fugitive` enable/disable fugitive integration * `g:airline_enable_fugitive` enable/disable fugitive integration
* `g:airline_enable_syntastic` enable/disable syntastic integration * `g:airline_enable_syntastic` enable/disable syntastic integration
* `g:airline_powerline_fonts` enable/disable usage of patched powerline font symbols
# contributions # contributions
contributions and pull requests are welcome. please make sure to keep it as light as possible. contributions and pull requests are welcome.
# license # license

View File

@ -1,9 +1,10 @@
" some symbols: ▶ » « ◀ " powerline symbols:       
" some unicode symbols: ▶ » « ◀
if !exists('g:airline_left_sep') if !exists('g:airline_left_sep')
let g:airline_left_sep="»" let g:airline_left_sep=exists('g:airline_powerline_fonts')?"":"»"
endif endif
if !exists('g:airline_right_sep') if !exists('g:airline_right_sep')
let g:airline_right_sep="«" let g:airline_right_sep=exists('g:airline_powerline_fonts')?"":"«"
endif endif
if !exists('g:airline_enable_fugitive') if !exists('g:airline_enable_fugitive')
let g:airline_enable_fugitive = 1 let g:airline_enable_fugitive = 1
@ -11,6 +12,9 @@ endif
if !exists('g:airline_enable_syntastic') if !exists('g:airline_enable_syntastic')
let g:airline_enable_syntastic = 1 let g:airline_enable_syntastic = 1
endif endif
let g:airline_fugitive_prefix = exists('g:airline_powerline_fonts')?'  ':' '
let g:airline_readonly_symbol = exists('g:airline_powerline_fonts')?'':'RO'
let g:airline_linecolumn_prefix = exists('g:airline_powerline_fonts')?' ':':'
set laststatus=2 set laststatus=2
@ -98,7 +102,7 @@ function! AirlineModePrefix()
endif endif
endfunction endfunction
" init colors " init colors on startup
call AirlineModePrefix() call AirlineModePrefix()
function! s:update_statusline(active) function! s:update_statusline(active)
@ -111,7 +115,7 @@ function! s:update_statusline(active)
let sl = a:active ? l:mode_color."%{AirlineModePrefix()}".l:mode_sep_color : l:mode_color." NORMAL %9*" let sl = a:active ? l:mode_color."%{AirlineModePrefix()}".l:mode_sep_color : l:mode_color." NORMAL %9*"
let sl.="%{g:airline_left_sep}".l:info_color let sl.="%{g:airline_left_sep}".l:info_color
let sl.="\ %{g:airline_enable_fugitive&&exists('g:loaded_fugitive')?fugitive#head():''}\ " let sl.="%{g:airline_enable_fugitive&&exists('g:loaded_fugitive')? g:airline_fugitive_prefix.fugitive#head():''}\ "
let sl.=l:info_sep_color."%{g:airline_left_sep}" let sl.=l:info_sep_color."%{g:airline_left_sep}"
if a:active if a:active
let sl.=l:status_color."\ %{exists('g:bufferline_loaded')?bufferline#generate_string():'%f'}\ " let sl.=l:status_color."\ %{exists('g:bufferline_loaded')?bufferline#generate_string():'%f'}\ "
@ -120,14 +124,13 @@ function! s:update_statusline(active)
endif endif
let sl.="%#warningmsg#" let sl.="%#warningmsg#"
let sl.="%{g:airline_enable_syntastic&&exists('g:loaded_syntastic_plugin')?SyntasticStatuslineFlag():''}" let sl.="%{g:airline_enable_syntastic&&exists('g:loaded_syntastic_plugin')?SyntasticStatuslineFlag():''}"
let sl.=l:status_color."%<%=".l:file_flag_color."%{&ro?'RO':''}" let sl.=l:status_color."%<%=".l:file_flag_color."%{&ro? g:airline_readonly_symbol :''}"
let sl.=l:status_color."\ %{strlen(&filetype)>0?&filetype:''}\ " let sl.=l:status_color."\ %{strlen(&filetype)>0?&filetype:''}\ "
let sl.=l:info_sep_color."%{g:airline_right_sep}" let sl.=l:info_sep_color."%{g:airline_right_sep}".l:info_color."\ "
let sl.=l:info_color."\ "
let sl.="%{strlen(&fileencoding)>0?&fileencoding:''}" let sl.="%{strlen(&fileencoding)>0?&fileencoding:''}"
let sl.="%{strlen(&fileformat)>0?'['.&fileformat.']':''}" let sl.="%{strlen(&fileformat)>0?'['.&fileformat.']':''}"
let sl.="\ ".l:mode_sep_color."%{g:airline_right_sep}" let sl.="\ ".l:mode_sep_color."%{g:airline_right_sep}"
let sl.=l:mode_color."\ %3p%%\ :\ %3l:%3c\ " let sl.=l:mode_color."\ %3p%%\ ".g:airline_linecolumn_prefix."%3l:%3c\ "
call setwinvar(winnr(), '&statusline', sl) call setwinvar(winnr(), '&statusline', sl)
endfunction endfunction