extract tabline colors from the current palette.
This commit is contained in:
parent
ecccf51401
commit
345a60fb23
@ -2,6 +2,8 @@
|
|||||||
" vim: et ts=2 sts=2 sw=2
|
" vim: et ts=2 sts=2 sw=2
|
||||||
|
|
||||||
let s:ext = {}
|
let s:ext = {}
|
||||||
|
let s:ext._theme_funcrefs = []
|
||||||
|
|
||||||
function! s:ext.add_statusline_func(name) dict
|
function! s:ext.add_statusline_func(name) dict
|
||||||
call airline#add_statusline_func(a:name)
|
call airline#add_statusline_func(a:name)
|
||||||
endfunction
|
endfunction
|
||||||
@ -11,6 +13,9 @@ endfunction
|
|||||||
function! s:ext.add_inactive_statusline_func(name) dict
|
function! s:ext.add_inactive_statusline_func(name) dict
|
||||||
call airline#add_inactive_statusline_func(a:name)
|
call airline#add_inactive_statusline_func(a:name)
|
||||||
endfunction
|
endfunction
|
||||||
|
function! s:ext.add_theme_func(name) dict
|
||||||
|
call add(self._theme_funcrefs, function(a:name))
|
||||||
|
endfunction
|
||||||
|
|
||||||
let s:script_path = resolve(expand('<sfile>:p:h'))
|
let s:script_path = resolve(expand('<sfile>:p:h'))
|
||||||
|
|
||||||
@ -109,9 +114,7 @@ function! s:is_excluded_window()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#load_theme()
|
function! airline#extensions#load_theme()
|
||||||
if get(g:, 'loaded_ctrlp', 0)
|
call airline#util#exec_funcrefs(s:ext._theme_funcrefs, g:airline#themes#{g:airline_theme}#palette)
|
||||||
call airline#extensions#ctrlp#load_theme()
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:sync_active_winnr()
|
function! s:sync_active_winnr()
|
||||||
|
@ -14,15 +14,15 @@ function! airline#extensions#ctrlp#generate_color_map(dark, light, white)
|
|||||||
\ }
|
\ }
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#ctrlp#load_theme()
|
function! airline#extensions#ctrlp#load_theme(palette)
|
||||||
if exists('g:airline#themes#{g:airline_theme}#palette.ctrlp')
|
if exists('a:palette.ctrlp')
|
||||||
let theme = g:airline#themes#{g:airline_theme}#palette.ctrlp
|
let theme = a:palette.ctrlp
|
||||||
else
|
else
|
||||||
let s:color_template = has_key(g:airline#themes#{g:airline_theme}#palette, s:color_template) ? s:color_template : 'insert'
|
let s:color_template = has_key(a:palette, s:color_template) ? s:color_template : 'insert'
|
||||||
let theme = airline#extensions#ctrlp#generate_color_map(
|
let theme = airline#extensions#ctrlp#generate_color_map(
|
||||||
\ g:airline#themes#{g:airline_theme}#palette[s:color_template]['airline_c'],
|
\ a:palette[s:color_template]['airline_c'],
|
||||||
\ g:airline#themes#{g:airline_theme}#palette[s:color_template]['airline_b'],
|
\ a:palette[s:color_template]['airline_b'],
|
||||||
\ g:airline#themes#{g:airline_theme}#palette[s:color_template]['airline_a'])
|
\ a:palette[s:color_template]['airline_a'])
|
||||||
endif
|
endif
|
||||||
for key in keys(theme)
|
for key in keys(theme)
|
||||||
call airline#highlighter#exec(key, theme[key])
|
call airline#highlighter#exec(key, theme[key])
|
||||||
@ -60,5 +60,6 @@ function! airline#extensions#ctrlp#init(ext)
|
|||||||
\ 'prog': 'airline#extensions#ctrlp#ctrlp_airline_status',
|
\ 'prog': 'airline#extensions#ctrlp#ctrlp_airline_status',
|
||||||
\ }
|
\ }
|
||||||
call a:ext.add_statusline_func('airline#extensions#ctrlp#apply')
|
call a:ext.add_statusline_func('airline#extensions#ctrlp#apply')
|
||||||
|
call a:ext.add_theme_func('airline#extensions#ctrlp#load_theme')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -3,6 +3,19 @@
|
|||||||
|
|
||||||
function! airline#extensions#tabline#init(ext)
|
function! airline#extensions#tabline#init(ext)
|
||||||
set tabline=%!airline#extensions#tabline#get()
|
set tabline=%!airline#extensions#tabline#get()
|
||||||
|
|
||||||
|
call a:ext.add_theme_func('airline#extensions#tabline#load_theme')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#extensions#tabline#load_theme(palette)
|
||||||
|
let fill = a:palette.normal.airline_c
|
||||||
|
let normal = a:palette.normal.airline_b
|
||||||
|
let selected = a:palette.normal.airline_a
|
||||||
|
let type = a:palette.visual.airline_a
|
||||||
|
call airline#highlighter#exec('airline_tabline', normal)
|
||||||
|
call airline#highlighter#exec('airline_tablinesel', selected)
|
||||||
|
call airline#highlighter#exec('airline_tablinetype', type)
|
||||||
|
call airline#highlighter#exec('airline_tablinefill', fill)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#tabline#get()
|
function! airline#extensions#tabline#get()
|
||||||
@ -14,29 +27,29 @@ function! airline#extensions#tabline#get()
|
|||||||
for nr in range(1, bufnr('$'))
|
for nr in range(1, bufnr('$'))
|
||||||
if buflisted(nr) && bufexists(nr)
|
if buflisted(nr) && bufexists(nr)
|
||||||
if cur == nr
|
if cur == nr
|
||||||
call b.add_section('TabLineSel', '%( %{fnamemodify(bufname('.nr.'), ":t")} %)')
|
call b.add_section('airline_tablinesel', '%( %{fnamemodify(bufname('.nr.'), ":t")} %)')
|
||||||
else
|
else
|
||||||
call b.add_section('TabLine', '%( %{fnamemodify(bufname('.nr.'), ":t")} %)')
|
call b.add_section('airline_tabline', '%( %{fnamemodify(bufname('.nr.'), ":t")} %)')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
call b.add_section('TabLineFill', '')
|
call b.add_section('airline_tablinefill', '')
|
||||||
call b.split()
|
call b.split()
|
||||||
call b.add_section('TabLineSel', ' buffers ')
|
call b.add_section('airline_tablinetype', ' buffers ')
|
||||||
else
|
else
|
||||||
let s = ''
|
let s = ''
|
||||||
for i in range(tabpagenr('$'))
|
for i in range(tabpagenr('$'))
|
||||||
if i + 1 == tabpagenr()
|
if i + 1 == tabpagenr()
|
||||||
call b.add_section('TabLineSel', '%( %'.(i+1).'T %{airline#extensions#tabline#title('.(i+1).')} %)')
|
call b.add_section('airline_tablinesel', '%( %'.(i+1).'T %{airline#extensions#tabline#title('.(i+1).')} %)')
|
||||||
else
|
else
|
||||||
call b.add_section('TabLine', '%( %'.(i+1).'T %{airline#extensions#tabline#title('.(i+1).')} %)')
|
call b.add_section('airline_tabline', '%( %'.(i+1).'T %{airline#extensions#tabline#title('.(i+1).')} %)')
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
call b.add_raw('%T')
|
call b.add_raw('%T')
|
||||||
call b.add_section('TabLineFill', '')
|
call b.add_section('airline_tablinefill', '')
|
||||||
call b.split()
|
call b.split()
|
||||||
call b.add_section('TabLine', ' %999XX ')
|
call b.add_section('airline_tabline', ' %999XX ')
|
||||||
call b.add_section('TabLineSel', ' tabs ')
|
call b.add_section('airline_tablinetype', ' tabs ')
|
||||||
endif
|
endif
|
||||||
return b.build()
|
return b.build()
|
||||||
endfunction
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user