clearly separate core functionality from implementation

This commit is contained in:
Bailey Ling
2013-07-25 22:29:18 +00:00
parent ec86f66510
commit bce1632c42
3 changed files with 36 additions and 20 deletions

View File

@@ -1,5 +1,6 @@
" vim: ts=2 sts=2 sw=2 fdm=indent
let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running')
let s:sections = ['a','b','c','gutter','x','y','z']
let s:airline_highlight_map = {
\ 'mode' : 'Al2',
@@ -49,22 +50,24 @@ function! airline#highlight(modes)
endfunction
function! s:is_excluded_window()
for matchft in g:airline_exclude_filetypes
if matchft ==# &ft
for Fn in g:airline_exclude_funcrefs
if Fn()
return 1
endif
endfor
for matchw in g:airline_exclude_filenames
if matchstr(expand('%'), matchw) ==# matchw
return 1
endif
endfor
if g:airline_exclude_preview && &previewwindow
return 1
endif
return 0
endfunction
function! s:apply_window_overrides()
unlet! w:airline_left_only
for section in s:sections
unlet! w:airline_section_{section}
endfor
for Fn in g:airline_window_override_funcrefs
call Fn()
endfor
endfunction
function! airline#update_externals()
let g:airline_externals_bufferline = g:airline_enable_bufferline && exists('*bufferline#get_status_string')
\ ? '%{bufferline#refresh_status()}'.bufferline#get_status_string()
@@ -87,7 +90,7 @@ function! airline#update_statusline(active)
endif
call airline#update_externals()
call airline#extensions#apply_window_overrides()
call s:apply_window_overrides()
let l:mode_color = a:active ? "%#Al2#" : "%#Al2_inactive#"
let l:mode_sep_color = a:active ? "%#Al3#" : "%#Al3_inactive#"

View File

@@ -1,5 +1,3 @@
let s:sections = ['a','b','c','gutter','x','y','z']
function! airline#extensions#apply_left_override(section1, section2)
let w:airline_section_a = a:section1
let w:airline_section_b = a:section2
@@ -8,11 +6,6 @@ function! airline#extensions#apply_left_override(section1, section2)
endfunction
function! airline#extensions#apply_window_overrides()
unlet! w:airline_left_only
for section in s:sections
unlet! w:airline_section_{section}
endfor
if &buftype == 'quickfix'
let w:airline_section_a = 'Quickfix'
let w:airline_section_b = ''
@@ -50,10 +43,26 @@ function! airline#extensions#apply_window_overrides()
elseif &ft == 'minibufexpl'
call airline#extensions#apply_left_override('MiniBufExplorer', '')
endif
endfunction
for Fn in g:airline_window_override_funcrefs
call Fn()
function! airline#extensions#is_excluded_window()
for matchft in g:airline_exclude_filetypes
if matchft ==# &ft
return 1
endif
endfor
for matchw in g:airline_exclude_filenames
if matchstr(expand('%'), matchw) ==# matchw
return 1
endif
endfor
if g:airline_exclude_preview && &previewwindow
return 1
endif
return 0
endfunction
function! airline#extensions#load()
@@ -81,5 +90,8 @@ function! airline#extensions#load()
let g:bufferline_active_buffer_right = ''
let g:bufferline_separator = ' '
endif
call add(g:airline_window_override_funcrefs, function('airline#extensions#apply_window_overrides'))
call add(g:airline_exclude_funcrefs, function('airline#extensions#is_excluded_window'))
endfunction