add profiler. optimize separator highlighting.

This commit is contained in:
Bailey Ling 2013-08-17 17:35:06 +00:00
parent 47bfeee3ae
commit 3fbdd28e5d
7 changed files with 55 additions and 30 deletions

View File

@ -1,21 +1,20 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 fdm=indent
" vim: et ts=2 sts=2 sw=2
let s:sections = ['a','b','c','gutter','x','y','z','warning']
let s:highlighter = airline#highlighter#new()
function! airline#reload_highlight()
call s:highlighter.highlight(['inactive'])
call s:highlighter.highlight(['normal'])
function! airline#load_theme()
call s:highlighter.load_theme()
call airline#extensions#load_theme()
endfunction
function! airline#load_theme(name)
function! airline#switch_theme(name)
let g:airline_theme = a:name
let inactive_colors = g:airline#themes#{g:airline_theme}#inactive "also lazy loads the theme
let w:airline_lastmode = ''
call airline#update_statusline()
call airline#reload_highlight()
call airline#load_theme()
call airline#check_mode()
endfunction
@ -109,3 +108,4 @@ function! airline#check_mode()
endif
return ''
endfunction

View File

@ -0,0 +1,15 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
function! airline#debug#profile()
profile start airline-profile.log
profile func *
profile file *
split
for i in range(1, 50)
wincmd w
redrawstatus
endfor
profile pause
noautocmd qall!
endfunction

View File

@ -1,5 +1,5 @@
" MIT license. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 fdm=indent
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running')
@ -19,20 +19,25 @@ function! airline#highlighter#exec(group, colors)
\ get(colors, 4, '') != '' ? 'term='.colors[4] : '')
endfunction
function! airline#highlighter#exec_separator(from, to)
if a:from == a:to
return a:from
endif
function! airline#highlighter#exec_separator(dict, from, to)
let l:from = airline#themes#get_highlight(a:from)
let l:to = airline#themes#get_highlight(a:to)
let group = a:from.'_to_'.a:to
call airline#highlighter#exec(group, [ l:to[1], l:from[1], l:to[3], l:from[3] ])
return group
let colors = [ l:to[1], l:from[1], l:to[3], l:from[3] ]
let a:dict[group] = colors
call airline#highlighter#exec(group, colors)
endfunction
function! airline#highlighter#new()
let highlighter = {}
let highlighter._separators = []
let highlighter._init_separators = {}
function! highlighter.load_theme()
let self._init_separators = {}
call self.highlight(['inactive'])
call self.highlight(['normal'])
endfunction
function! highlighter.add_separator(from, to)
call add(self._separators, [a:from, a:to])
@ -44,16 +49,19 @@ function! airline#highlighter#new()
let suffix = a:modes[0] == 'inactive' ? '_inactive' : ''
for mode in mapped
if exists('g:airline#themes#{g:airline_theme}#{mode}')
for key in keys(g:airline#themes#{g:airline_theme}#{mode})
let colors = g:airline#themes#{g:airline_theme}#{mode}[key]
call airline#highlighter#exec(key.suffix, colors)
endfor
endif
let dict = g:airline#themes#{g:airline_theme}#{mode}
for kvp in items(dict)
call airline#highlighter#exec(kvp[0].suffix, kvp[1])
endfor
" synchronize separator colors
" initialize separator colors for this mode if necessary
if !has_key(self._init_separators, mode)
let self._init_separators[mode] = 1
for sep in self._separators
call airline#highlighter#exec_separator(sep[0].suffix, sep[1].suffix)
call airline#highlighter#exec_separator(dict, sep[0].suffix, sep[1].suffix)
endfor
endif
endif
endfor
endfunction

View File

@ -166,5 +166,5 @@ endfunction
call s:generate()
augroup airline_solarized
autocmd!
autocmd ColorScheme * call <sid>generate() | call airline#reload_highlight()
autocmd ColorScheme * call <sid>generate() | call airline#load_theme()
augroup END

View File

@ -39,5 +39,5 @@ endfunction
call s:generate()
augroup airline_tomorrow
autocmd!
autocmd ColorScheme * call <sid>generate() | call airline#reload_highlight()
autocmd ColorScheme * call <sid>generate() | call airline#load_theme()
augroup END

View File

@ -1,5 +1,5 @@
" MIT license. Copyright (c) 2013 Bailey Ling.
" vim: ts=2 sts=2 sw=2 fdm=indent
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
" for 7.2 compatibility
function! airline#util#getwinvar(winnr, key, ...)
@ -22,3 +22,4 @@ function! airline#util#exec_funcrefs(list, break_early)
endfor
return 0
endfunction

View File

@ -1,5 +1,5 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 fdm=indent
" vim: et ts=2 sts=2 sw=2
if &cp || v:version < 702 || (exists('g:loaded_airline') && g:loaded_airline)
finish
@ -66,7 +66,7 @@ let s:airline_initialized = 0
function! s:on_window_changed()
if !s:airline_initialized
call airline#extensions#load()
call airline#load_theme(g:airline_theme)
call airline#switch_theme(g:airline_theme)
let s:airline_initialized = 1
endif
call airline#update_statusline()
@ -95,7 +95,7 @@ function! s:airline_toggle()
\ | call <sid>on_window_changed()
autocmd CmdwinLeave * call remove(g:airline_statusline_funcrefs, -1)
autocmd ColorScheme * call airline#reload_highlight()
autocmd ColorScheme * call airline#load_theme()
autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost *
\ call <sid>on_window_changed()
augroup END
@ -111,7 +111,7 @@ function! s:get_airline_themes(a, l, p)
endfunction
function! s:airline_theme(...)
if a:0
call airline#load_theme(a:1)
call airline#switch_theme(a:1)
else
echo g:airline_theme
endif
@ -121,3 +121,4 @@ command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle()
command! AirlineToggle call <sid>airline_toggle()
call <sid>airline_toggle()