mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-12-06 12:14:24 +08:00
extract all plugin related functionality out of the core
This commit is contained in:
@@ -104,7 +104,7 @@ function! s:get_statusline(winnr, active)
|
||||
return sl
|
||||
endfunction
|
||||
|
||||
function! s:exec_funcrefs(list, break_early)
|
||||
function! airline#exec_funcrefs(list, break_early)
|
||||
" for 7.2; we cannot iterate list, hence why we use range()
|
||||
" for 7.3-[97, 328]; we cannot reuse the variable, hence the {}
|
||||
for i in range(0, len(a:list) - 1)
|
||||
@@ -121,7 +121,7 @@ function! s:exec_funcrefs(list, break_early)
|
||||
endfunction
|
||||
|
||||
function! airline#update_statusline()
|
||||
if s:exec_funcrefs(g:airline_exclude_funcrefs, 1)
|
||||
if airline#exec_funcrefs(g:airline_exclude_funcrefs, 1)
|
||||
call setwinvar(winnr(), '&statusline', '')
|
||||
return
|
||||
endif
|
||||
@@ -130,7 +130,7 @@ function! airline#update_statusline()
|
||||
for section in s:sections
|
||||
unlet! w:airline_section_{section}
|
||||
endfor
|
||||
call s:exec_funcrefs(g:airline_statusline_funcrefs, 0)
|
||||
call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0)
|
||||
|
||||
let w:airline_active = 1
|
||||
call setwinvar(winnr(), '&statusline', s:get_statusline(winnr(), 1))
|
||||
|
||||
@@ -18,7 +18,10 @@ function! airline#extensions#apply_left_override(section1, section2)
|
||||
let w:airline_left_only = 1
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#apply_window_overrides()
|
||||
let s:active_winnr = -1
|
||||
function! airline#extensions#update_statusline()
|
||||
let s:active_winnr = winnr()
|
||||
|
||||
if &buftype == 'quickfix'
|
||||
let w:airline_section_a = 'Quickfix'
|
||||
let w:airline_section_b = ''
|
||||
@@ -90,19 +93,33 @@ function! airline#extensions#load_theme()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:sync_active_winnr()
|
||||
if winnr() != s:active_winnr
|
||||
if airline#exec_funcrefs(s:ext._cursormove_funcrefs, 1)
|
||||
return
|
||||
endif
|
||||
call airline#update_statusline()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#load()
|
||||
" non-trivial number of external plugins use eventignore=all, so we need to account for that
|
||||
autocmd CursorMoved * call <sid>sync_active_winnr()
|
||||
|
||||
" load core funcrefs
|
||||
call add(g:airline_exclude_funcrefs, function('airline#extensions#is_excluded_window'))
|
||||
call add(g:airline_statusline_funcrefs, function('airline#extensions#update_statusline'))
|
||||
|
||||
if get(g:, 'loaded_unite', 0)
|
||||
let g:unite_force_overwrite_statusline = 0
|
||||
endif
|
||||
|
||||
if get(g:, 'loaded_vimfiler', 0)
|
||||
let g:vimfiler_force_overwrite_statusline = 0
|
||||
endif
|
||||
|
||||
if get(g:, 'loaded_ctrlp', 0)
|
||||
let g:ctrlp_status_func = {
|
||||
\ 'main': 'airline#extensions#ctrlp#ctrlp_airline',
|
||||
\ 'prog': 'airline#extensions#ctrlp#ctrlp_airline_status',
|
||||
\ }
|
||||
call airline#extensions#ctrlp#init(s:ext)
|
||||
endif
|
||||
|
||||
if get(g:, 'command_t_loaded', 0)
|
||||
@@ -125,9 +142,6 @@ function! airline#extensions#load()
|
||||
call airline#extensions#bufferline#init(s:ext)
|
||||
endif
|
||||
|
||||
call add(g:airline_statusline_funcrefs, function('airline#extensions#apply_window_overrides'))
|
||||
call add(g:airline_exclude_funcrefs, function('airline#extensions#is_excluded_window'))
|
||||
|
||||
call airline#extensions#update_external_values()
|
||||
call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0)
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -26,10 +26,7 @@ function! airline#extensions#ctrlp#load_theme()
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" Recreate Ctrl-P status line with some slight modifications
|
||||
|
||||
" Arguments: focus, byfname, s:regexp, prv, item, nxt, marked
|
||||
" a:1 a:2 a:3 a:4 a:5 a:6 a:7
|
||||
function! airline#extensions#ctrlp#ctrlp_airline(...)
|
||||
let regex = a:3 ? '%#CtrlPlight# regex %*' : ''
|
||||
let prv = '%#CtrlPlight# '.a:4.' %#Ctrlparrow1#'.g:airline_left_sep
|
||||
@@ -39,15 +36,24 @@ function! airline#extensions#ctrlp#ctrlp_airline(...)
|
||||
let focus = '%=%<%#CtrlPdark# '.a:1.' %*'
|
||||
let byfname = '%#CtrlParrow3#'.g:airline_right_alt_sep.'%#CtrlPdark# '.a:2.' %*'
|
||||
let dir = '%#CtrlParrow3#'.g:airline_right_sep.'%#CtrlPlight# '.getcwd().' %*'
|
||||
" Return the full statusline
|
||||
return regex.prv.item.nxt.marked.focus.byfname.dir
|
||||
endfunction
|
||||
|
||||
" Argument: len
|
||||
" a:1
|
||||
function! airline#extensions#ctrlp#ctrlp_airline_status(...)
|
||||
let len = '%#CtrlPdark# '.a:1
|
||||
let dir = '%=%<%#CtrlParrow3#'.g:airline_right_sep.'%#CtrlPlight# '.getcwd().' %*'
|
||||
" Return the full statusline
|
||||
return len.dir
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#ctrlp#is_statusline_overwritten()
|
||||
return match(&statusline, 'CtrlPlight') >= 0
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#ctrlp#init(ext)
|
||||
let g:ctrlp_status_func = {
|
||||
\ 'main': 'airline#extensions#ctrlp#ctrlp_airline',
|
||||
\ 'prog': 'airline#extensions#ctrlp#ctrlp_airline_status',
|
||||
\ }
|
||||
call a:ext.add_cursormove_funcref(function('airline#extensions#ctrlp#is_statusline_overwritten'))
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user