mirror of
https://github.com/vim-airline/vim-airline-themes.git
synced 2024-12-11 20:54:27 +08:00
add profiler. optimize separator highlighting.
This commit is contained in:
parent
47bfeee3ae
commit
3fbdd28e5d
|
@ -1,21 +1,20 @@
|
||||||
" MIT License. Copyright (c) 2013 Bailey Ling.
|
" 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:sections = ['a','b','c','gutter','x','y','z','warning']
|
||||||
let s:highlighter = airline#highlighter#new()
|
let s:highlighter = airline#highlighter#new()
|
||||||
|
|
||||||
function! airline#reload_highlight()
|
function! airline#load_theme()
|
||||||
call s:highlighter.highlight(['inactive'])
|
call s:highlighter.load_theme()
|
||||||
call s:highlighter.highlight(['normal'])
|
|
||||||
call airline#extensions#load_theme()
|
call airline#extensions#load_theme()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#load_theme(name)
|
function! airline#switch_theme(name)
|
||||||
let g:airline_theme = a:name
|
let g:airline_theme = a:name
|
||||||
let inactive_colors = g:airline#themes#{g:airline_theme}#inactive "also lazy loads the theme
|
let inactive_colors = g:airline#themes#{g:airline_theme}#inactive "also lazy loads the theme
|
||||||
let w:airline_lastmode = ''
|
let w:airline_lastmode = ''
|
||||||
call airline#update_statusline()
|
call airline#update_statusline()
|
||||||
call airline#reload_highlight()
|
call airline#load_theme()
|
||||||
call airline#check_mode()
|
call airline#check_mode()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -109,3 +108,4 @@ function! airline#check_mode()
|
||||||
endif
|
endif
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
15
autoload/airline/debug.vim
Normal file
15
autoload/airline/debug.vim
Normal 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
|
|
@ -1,5 +1,5 @@
|
||||||
" MIT license. Copyright (c) 2013 Bailey Ling.
|
" 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:is_win32term = (has('win32') || has('win64')) && !has('gui_running')
|
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] : '')
|
\ get(colors, 4, '') != '' ? 'term='.colors[4] : '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#highlighter#exec_separator(from, to)
|
function! airline#highlighter#exec_separator(dict, from, to)
|
||||||
if a:from == a:to
|
|
||||||
return a:from
|
|
||||||
endif
|
|
||||||
let l:from = airline#themes#get_highlight(a:from)
|
let l:from = airline#themes#get_highlight(a:from)
|
||||||
let l:to = airline#themes#get_highlight(a:to)
|
let l:to = airline#themes#get_highlight(a:to)
|
||||||
let group = a:from.'_to_'.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] ])
|
let colors = [ l:to[1], l:from[1], l:to[3], l:from[3] ]
|
||||||
return group
|
let a:dict[group] = colors
|
||||||
|
call airline#highlighter#exec(group, colors)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#highlighter#new()
|
function! airline#highlighter#new()
|
||||||
let highlighter = {}
|
let highlighter = {}
|
||||||
let highlighter._separators = []
|
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)
|
function! highlighter.add_separator(from, to)
|
||||||
call add(self._separators, [a:from, a:to])
|
call add(self._separators, [a:from, a:to])
|
||||||
|
@ -44,16 +49,19 @@ function! airline#highlighter#new()
|
||||||
let suffix = a:modes[0] == 'inactive' ? '_inactive' : ''
|
let suffix = a:modes[0] == 'inactive' ? '_inactive' : ''
|
||||||
for mode in mapped
|
for mode in mapped
|
||||||
if exists('g:airline#themes#{g:airline_theme}#{mode}')
|
if exists('g:airline#themes#{g:airline_theme}#{mode}')
|
||||||
for key in keys(g:airline#themes#{g:airline_theme}#{mode})
|
let dict = g:airline#themes#{g:airline_theme}#{mode}
|
||||||
let colors = g:airline#themes#{g:airline_theme}#{mode}[key]
|
for kvp in items(dict)
|
||||||
call airline#highlighter#exec(key.suffix, colors)
|
call airline#highlighter#exec(kvp[0].suffix, kvp[1])
|
||||||
endfor
|
endfor
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" synchronize separator colors
|
" initialize separator colors for this mode if necessary
|
||||||
for sep in self._separators
|
if !has_key(self._init_separators, mode)
|
||||||
call airline#highlighter#exec_separator(sep[0].suffix, sep[1].suffix)
|
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
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -166,5 +166,5 @@ endfunction
|
||||||
call s:generate()
|
call s:generate()
|
||||||
augroup airline_solarized
|
augroup airline_solarized
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd ColorScheme * call <sid>generate() | call airline#reload_highlight()
|
autocmd ColorScheme * call <sid>generate() | call airline#load_theme()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
|
@ -39,5 +39,5 @@ endfunction
|
||||||
call s:generate()
|
call s:generate()
|
||||||
augroup airline_tomorrow
|
augroup airline_tomorrow
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd ColorScheme * call <sid>generate() | call airline#reload_highlight()
|
autocmd ColorScheme * call <sid>generate() | call airline#load_theme()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
" MIT license. Copyright (c) 2013 Bailey Ling.
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
||||||
" vim: ts=2 sts=2 sw=2 fdm=indent
|
" vim: et ts=2 sts=2 sw=2
|
||||||
|
|
||||||
" for 7.2 compatibility
|
" for 7.2 compatibility
|
||||||
function! airline#util#getwinvar(winnr, key, ...)
|
function! airline#util#getwinvar(winnr, key, ...)
|
||||||
|
@ -22,3 +22,4 @@ function! airline#util#exec_funcrefs(list, break_early)
|
||||||
endfor
|
endfor
|
||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
" MIT License. Copyright (c) 2013 Bailey Ling.
|
" 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)
|
if &cp || v:version < 702 || (exists('g:loaded_airline') && g:loaded_airline)
|
||||||
finish
|
finish
|
||||||
|
@ -66,7 +66,7 @@ let s:airline_initialized = 0
|
||||||
function! s:on_window_changed()
|
function! s:on_window_changed()
|
||||||
if !s:airline_initialized
|
if !s:airline_initialized
|
||||||
call airline#extensions#load()
|
call airline#extensions#load()
|
||||||
call airline#load_theme(g:airline_theme)
|
call airline#switch_theme(g:airline_theme)
|
||||||
let s:airline_initialized = 1
|
let s:airline_initialized = 1
|
||||||
endif
|
endif
|
||||||
call airline#update_statusline()
|
call airline#update_statusline()
|
||||||
|
@ -95,7 +95,7 @@ function! s:airline_toggle()
|
||||||
\ | call <sid>on_window_changed()
|
\ | call <sid>on_window_changed()
|
||||||
autocmd CmdwinLeave * call remove(g:airline_statusline_funcrefs, -1)
|
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 *
|
autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost *
|
||||||
\ call <sid>on_window_changed()
|
\ call <sid>on_window_changed()
|
||||||
augroup END
|
augroup END
|
||||||
|
@ -111,7 +111,7 @@ function! s:get_airline_themes(a, l, p)
|
||||||
endfunction
|
endfunction
|
||||||
function! s:airline_theme(...)
|
function! s:airline_theme(...)
|
||||||
if a:0
|
if a:0
|
||||||
call airline#load_theme(a:1)
|
call airline#switch_theme(a:1)
|
||||||
else
|
else
|
||||||
echo g:airline_theme
|
echo g:airline_theme
|
||||||
endif
|
endif
|
||||||
|
@ -121,3 +121,4 @@ command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle()
|
||||||
command! AirlineToggle call <sid>airline_toggle()
|
command! AirlineToggle call <sid>airline_toggle()
|
||||||
|
|
||||||
call <sid>airline_toggle()
|
call <sid>airline_toggle()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user