mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-21 13:04:54 +02:00
Warn if a function is already registered for inactive statusline
closes #2388
This commit is contained in:
parent
05bd105cab
commit
98aea41dc2
@ -4,22 +4,32 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
let g:airline_statusline_funcrefs = get(g:, 'airline_statusline_funcrefs', [])
|
||||
let g:airline_inactive_funcrefs = get(g:, 'airline_inactive_statusline_funcrefs', [])
|
||||
|
||||
let s:sections = ['a','b','c','gutter','x','y','z', 'error', 'warning']
|
||||
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)
|
||||
call airline#add_statusline_funcref(function(a:name))
|
||||
function! airline#add_statusline_func(name, ...)
|
||||
let warn = get(a:, 1, 1)
|
||||
call airline#add_statusline_funcref(function(a:name), warn)
|
||||
endfunction
|
||||
|
||||
function! airline#add_statusline_funcref(function)
|
||||
function! airline#add_inactive_statusline_func(name, ...)
|
||||
let warn = get(a:, 1, 1)
|
||||
call airline#add_inactive_statusline_funcref(function(a:name), warn)
|
||||
endfunction
|
||||
|
||||
|
||||
function! airline#add_statusline_funcref(function, ...)
|
||||
if index(g:airline_statusline_funcrefs, a:function) >= 0
|
||||
call airline#util#warning(printf('The airline statusline funcref "%s" has already been added.', string(a:function)))
|
||||
let warn = get(a:, 1, 1)
|
||||
if warn > 0
|
||||
call airline#util#warning(printf('The airline statusline funcref "%s" has already been added.', string(a:function)))
|
||||
endif
|
||||
return
|
||||
endif
|
||||
call add(g:airline_statusline_funcrefs, a:function)
|
||||
@ -32,8 +42,15 @@ function! airline#remove_statusline_func(name)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#add_inactive_statusline_func(name)
|
||||
call add(s:inactive_funcrefs, function(a:name))
|
||||
function! airline#add_inactive_statusline_funcref(function, ...)
|
||||
if index(g:airline_inactive_funcrefs, a:function) >= 0
|
||||
let warn = get(a:, 1, 1)
|
||||
if warn > 0
|
||||
call airline#util#warning(printf('The airline inactive statusline funcref "%s" has already been added.', string(a:function)))
|
||||
endif
|
||||
return
|
||||
endif
|
||||
call add(g:airline_inactive_funcrefs, function(a:function))
|
||||
endfunction
|
||||
|
||||
function! airline#load_theme()
|
||||
@ -168,7 +185,7 @@ function! airline#update_statusline_inactive(range)
|
||||
\ 'left_sep': g:airline_left_alt_sep,
|
||||
\ 'right_sep': g:airline_right_alt_sep }, 'keep')
|
||||
endif
|
||||
call s:invoke_funcrefs(context, s:inactive_funcrefs)
|
||||
call s:invoke_funcrefs(context, g:airline_inactive_funcrefs)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user