mirror of
https://github.com/vim-airline/vim-airline-themes.git
synced 2026-05-11 09:08:45 +08:00
add profiler. optimize separator highlighting.
This commit is contained in:
@@ -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)
|
||||
let dict = g:airline#themes#{g:airline_theme}#{mode}
|
||||
for kvp in items(dict)
|
||||
call airline#highlighter#exec(kvp[0].suffix, kvp[1])
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
|
||||
" synchronize separator colors
|
||||
for sep in self._separators
|
||||
call airline#highlighter#exec_separator(sep[0].suffix, sep[1].suffix)
|
||||
" 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(dict, sep[0].suffix, sep[1].suffix)
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user