mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-20 12:34:42 +02:00
autoload: add comments
This commit is contained in:
parent
99971aa24d
commit
f08078d683
@ -7,6 +7,11 @@ let g:airline_statusline_funcrefs = get(g:, 'airline_statusline_funcrefs', [])
|
|||||||
|
|
||||||
let s:sections = ['a','b','c','gutter','x','y','z', 'error', 'warning']
|
let s:sections = ['a','b','c','gutter','x','y','z', 'error', 'warning']
|
||||||
let s:inactive_funcrefs = []
|
let s:inactive_funcrefs = []
|
||||||
|
let s:contexts = {}
|
||||||
|
let s:core_funcrefs = [
|
||||||
|
\ function('airline#extensions#apply'),
|
||||||
|
\ function('airline#extensions#default#apply') ]
|
||||||
|
|
||||||
|
|
||||||
function! airline#add_statusline_func(name)
|
function! airline#add_statusline_func(name)
|
||||||
call airline#add_statusline_funcref(function(a:name))
|
call airline#add_statusline_funcref(function(a:name))
|
||||||
@ -52,6 +57,7 @@ function! airline#load_theme()
|
|||||||
call airline#update_statusline()
|
call airline#update_statusline()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Load an airline theme
|
||||||
function! airline#switch_theme(name)
|
function! airline#switch_theme(name)
|
||||||
try
|
try
|
||||||
let palette = g:airline#themes#{a:name}#palette "also lazy loads the theme
|
let palette = g:airline#themes#{a:name}#palette "also lazy loads the theme
|
||||||
@ -74,6 +80,7 @@ function! airline#switch_theme(name)
|
|||||||
call airline#check_mode(winnr())
|
call airline#check_mode(winnr())
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Try to load the right theme for the current colorscheme
|
||||||
function! airline#switch_matching_theme()
|
function! airline#switch_matching_theme()
|
||||||
if exists('g:colors_name')
|
if exists('g:colors_name')
|
||||||
let existing = g:airline_theme
|
let existing = g:airline_theme
|
||||||
@ -99,6 +106,7 @@ function! airline#switch_matching_theme()
|
|||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Update the statusline
|
||||||
function! airline#update_statusline()
|
function! airline#update_statusline()
|
||||||
if airline#util#getwinvar(winnr(), 'airline_disabled', 0)
|
if airline#util#getwinvar(winnr(), 'airline_disabled', 0)
|
||||||
return
|
return
|
||||||
@ -110,11 +118,14 @@ function! airline#update_statusline()
|
|||||||
unlet! w:airline_render_left w:airline_render_right
|
unlet! w:airline_render_left w:airline_render_right
|
||||||
exe 'unlet! ' 'w:airline_section_'. join(s:sections, ' w:airline_section_')
|
exe 'unlet! ' 'w:airline_section_'. join(s:sections, ' w:airline_section_')
|
||||||
|
|
||||||
|
" Now create the active statusline
|
||||||
let w:airline_active = 1
|
let w:airline_active = 1
|
||||||
let context = { 'winnr': winnr(), 'active': 1, 'bufnr': winbufnr(winnr()) }
|
let context = { 'winnr': winnr(), 'active': 1, 'bufnr': winbufnr(winnr()) }
|
||||||
call s:invoke_funcrefs(context, g:airline_statusline_funcrefs)
|
call s:invoke_funcrefs(context, g:airline_statusline_funcrefs)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Function to be called to make all statuslines inactive
|
||||||
|
" Triggered on FocusLost autocommand
|
||||||
function! airline#update_statusline_focuslost()
|
function! airline#update_statusline_focuslost()
|
||||||
if get(g:, 'airline_focuslost_inactive', 0)
|
if get(g:, 'airline_focuslost_inactive', 0)
|
||||||
let bufnr=bufnr('%')
|
let bufnr=bufnr('%')
|
||||||
@ -123,6 +134,8 @@ function! airline#update_statusline_focuslost()
|
|||||||
call airline#update_statusline_inactive(range(1, winnr('$')))
|
call airline#update_statusline_inactive(range(1, winnr('$')))
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Function to draw inactive statuslines for inactive windows
|
||||||
function! airline#update_statusline_inactive(range)
|
function! airline#update_statusline_inactive(range)
|
||||||
if airline#util#getwinvar(winnr(), 'airline_disabled', 0)
|
if airline#util#getwinvar(winnr(), 'airline_disabled', 0)
|
||||||
return
|
return
|
||||||
@ -137,10 +150,8 @@ function! airline#update_statusline_inactive(range)
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:contexts = {}
|
" Gather output from all funcrefs which will later be returned by the
|
||||||
let s:core_funcrefs = [
|
" airline#statusline() function
|
||||||
\ function('airline#extensions#apply'),
|
|
||||||
\ function('airline#extensions#default#apply') ]
|
|
||||||
function! s:invoke_funcrefs(context, funcrefs)
|
function! s:invoke_funcrefs(context, funcrefs)
|
||||||
let builder = airline#builder#new(a:context)
|
let builder = airline#builder#new(a:context)
|
||||||
let err = airline#util#exec_funcrefs(a:funcrefs + s:core_funcrefs, builder, a:context)
|
let err = airline#util#exec_funcrefs(a:funcrefs + s:core_funcrefs, builder, a:context)
|
||||||
@ -151,6 +162,8 @@ function! s:invoke_funcrefs(context, funcrefs)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Main statusline function per window
|
||||||
|
" will be set to the statusline option
|
||||||
function! airline#statusline(winnr)
|
function! airline#statusline(winnr)
|
||||||
if has_key(s:contexts, a:winnr)
|
if has_key(s:contexts, a:winnr)
|
||||||
return '%{airline#check_mode('.a:winnr.')}'.s:contexts[a:winnr].line
|
return '%{airline#check_mode('.a:winnr.')}'.s:contexts[a:winnr].line
|
||||||
@ -160,6 +173,7 @@ function! airline#statusline(winnr)
|
|||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Check if mode as changed
|
||||||
function! airline#check_mode(winnr)
|
function! airline#check_mode(winnr)
|
||||||
if !has_key(s:contexts, a:winnr)
|
if !has_key(s:contexts, a:winnr)
|
||||||
return ''
|
return ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user