mirror of
https://github.com/vim-airline/vim-airline-themes.git
synced 2024-12-05 08:30:03 +08:00
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
|
||||
|
||||
let s:ext = {}
|
||||
let s:ext._theme_funcrefs = []
|
||||
|
||||
function! s:ext.add_statusline_func(name) dict
|
||||
call airline#add_statusline_func(a:name)
|
||||
endfunction
|
||||
|
@ -11,6 +13,9 @@ endfunction
|
|||
function! s:ext.add_inactive_statusline_func(name) dict
|
||||
call airline#add_inactive_statusline_func(a:name)
|
||||
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'))
|
||||
|
||||
|
@ -109,9 +114,7 @@ function! s:is_excluded_window()
|
|||
endfunction
|
||||
|
||||
function! airline#extensions#load_theme()
|
||||
if get(g:, 'loaded_ctrlp', 0)
|
||||
call airline#extensions#ctrlp#load_theme()
|
||||
endif
|
||||
call airline#util#exec_funcrefs(s:ext._theme_funcrefs, g:airline#themes#{g:airline_theme}#palette)
|
||||
endfunction
|
||||
|
||||
function! s:sync_active_winnr()
|
||||
|
|
|
@ -14,15 +14,15 @@ function! airline#extensions#ctrlp#generate_color_map(dark, light, white)
|
|||
\ }
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#ctrlp#load_theme()
|
||||
if exists('g:airline#themes#{g:airline_theme}#palette.ctrlp')
|
||||
let theme = g:airline#themes#{g:airline_theme}#palette.ctrlp
|
||||
function! airline#extensions#ctrlp#load_theme(palette)
|
||||
if exists('a:palette.ctrlp')
|
||||
let theme = a:palette.ctrlp
|
||||
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(
|
||||
\ g:airline#themes#{g:airline_theme}#palette[s:color_template]['airline_c'],
|
||||
\ g:airline#themes#{g:airline_theme}#palette[s:color_template]['airline_b'],
|
||||
\ g:airline#themes#{g:airline_theme}#palette[s:color_template]['airline_a'])
|
||||
\ a:palette[s:color_template]['airline_c'],
|
||||
\ a:palette[s:color_template]['airline_b'],
|
||||
\ a:palette[s:color_template]['airline_a'])
|
||||
endif
|
||||
for key in keys(theme)
|
||||
call airline#highlighter#exec(key, theme[key])
|
||||
|
@ -60,5 +60,6 @@ function! airline#extensions#ctrlp#init(ext)
|
|||
\ 'prog': 'airline#extensions#ctrlp#ctrlp_airline_status',
|
||||
\ }
|
||||
call a:ext.add_statusline_func('airline#extensions#ctrlp#apply')
|
||||
call a:ext.add_theme_func('airline#extensions#ctrlp#load_theme')
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -3,6 +3,19 @@
|
|||
|
||||
function! airline#extensions#tabline#init(ext)
|
||||
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
|
||||
|
||||
function! airline#extensions#tabline#get()
|
||||
|
@ -14,29 +27,29 @@ function! airline#extensions#tabline#get()
|
|||
for nr in range(1, bufnr('$'))
|
||||
if buflisted(nr) && bufexists(nr)
|
||||
if cur == nr
|
||||
call b.add_section('TabLineSel', '%( %{fnamemodify(bufname('.nr.'), ":t")} %)')
|
||||
call b.add_section('airline_tablinesel', '%( %{fnamemodify(bufname('.nr.'), ":t")} %)')
|
||||
else
|
||||
call b.add_section('TabLine', '%( %{fnamemodify(bufname('.nr.'), ":t")} %)')
|
||||
call b.add_section('airline_tabline', '%( %{fnamemodify(bufname('.nr.'), ":t")} %)')
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call b.add_section('TabLineFill', '')
|
||||
call b.add_section('airline_tablinefill', '')
|
||||
call b.split()
|
||||
call b.add_section('TabLineSel', ' buffers ')
|
||||
call b.add_section('airline_tablinetype', ' buffers ')
|
||||
else
|
||||
let s = ''
|
||||
for i in range(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
|
||||
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
|
||||
endfor
|
||||
call b.add_raw('%T')
|
||||
call b.add_section('TabLineFill', '')
|
||||
call b.add_section('airline_tablinefill', '')
|
||||
call b.split()
|
||||
call b.add_section('TabLine', ' %999XX ')
|
||||
call b.add_section('TabLineSel', ' tabs ')
|
||||
call b.add_section('airline_tabline', ' %999XX ')
|
||||
call b.add_section('airline_tablinetype', ' tabs ')
|
||||
endif
|
||||
return b.build()
|
||||
endfunction
|
||||
|
|
Loading…
Reference in New Issue
Block a user