From 60cba9cfc42994f07a46a1ce93d0410239aae5d6 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 27 Jul 2013 20:16:13 +0000 Subject: [PATCH] refactor ctrlp themes with generate_color_map helper function --- autoload/airline/extensions/ctrlp.vim | 27 +++++++++++++++++---------- autoload/airline/themes/luna.vim | 15 ++++++--------- autoload/airline/themes/wombat.vim | 15 ++++++--------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/autoload/airline/extensions/ctrlp.vim b/autoload/airline/extensions/ctrlp.vim index 3348c3c7..8a884dfb 100644 --- a/autoload/airline/extensions/ctrlp.vim +++ b/autoload/airline/extensions/ctrlp.vim @@ -1,17 +1,24 @@ +function! airline#extensions#ctrlp#generate_color_map(dark, light, white) + return { + \ 'CtrlPdark' : a:dark, + \ 'CtrlPlight' : a:light, + \ 'CtrlPwhite' : a:white, + \ 'CtrlParrow1' : [ a:light[1] , a:white[1] , a:light[3] , a:white[3] , '' ] , + \ 'CtrlParrow2' : [ a:white[1] , a:light[1] , a:white[3] , a:light[3] , '' ] , + \ 'CtrlParrow3' : [ a:light[1] , a:dark[1] , a:light[3] , a:dark[3] , '' ] , + \ 'CtrlParrow4' : [ a:white[1] , a:dark[1] , a:white[3] , a:dark[3] , '' ] , + \ 'CtrlParrow5' : [ a:light[1] , a:light[0] , a:light[3] , a:light[2] , '' ] , + \ } +endfunction + function! airline#extensions#ctrlp#load_theme() if exists('g:airline#themes#{g:airline_theme}#ctrlp') let theme = g:airline#themes#{g:airline_theme}#ctrlp else - let theme = { - \ 'CtrlPdark' : [ '#d7d7ff' , '#5f00af' , 189 , 55 , '' ] , - \ 'CtrlPlight' : [ '#ffffff' , '#875fd7' , 231 , 98 , '' ] , - \ 'CtrlPwhite' : [ '#5f00af' , '#ffffff' , 55 , 231 , 'bold' ] , - \ 'CtrlParrow1' : [ '#875fd7' , '#ffffff' , 98 , 231 , '' ] , - \ 'CtrlParrow2' : [ '#ffffff' , '#875fd7' , 231 , 98 , '' ] , - \ 'CtrlParrow3' : [ '#875fd7' , '#5f00af' , 98 , 55 , '' ] , - \ 'CtrlParrow4' : [ '#ffffff' , '#5f00af' , 231 , 55 , '' ] , - \ 'CtrlParrow5' : [ '#875fd7' , '#ffffff' , 98 , 231 , '' ] , - \ } + let theme = airline#extensions#ctrlp#generate_color_map( + \ [ '#d7d7ff' , '#5f00af' , 189 , 55 , '' ], + \ [ '#ffffff' , '#875fd7' , 231 , 98 , '' ], + \ [ '#5f00af' , '#ffffff' , 55 , 231 , 'bold' ]) endif for key in keys(theme) call airline#exec_highlight(key, theme[key]) diff --git a/autoload/airline/themes/luna.vim b/autoload/airline/themes/luna.vim index 722ea6b3..38f7e02b 100644 --- a/autoload/airline/themes/luna.vim +++ b/autoload/airline/themes/luna.vim @@ -48,12 +48,9 @@ let g:airline#themes#luna#inactive_modified = { \ 'statusline': [ '#f88379' , '' , '210' , '' , '' ] , \ } -let g:airline#themes#luna#ctrlp = { - \ 'CtrlPdark' : [ '#ffffff' , '#002b2b' , 231 , 23 , '' ] , - \ 'CtrlPlight' : [ '#ffffff' , '#005252' , 231 , 36 , '' ] , - \ 'CtrlPwhite' : [ '#ffffff' , '#973d45' , 231 , 95 , '' ] , - \ 'CtrlParrow1' : [ '#005252' , '#973d45' , 36 , 95 , '' ] , - \ 'CtrlParrow2' : [ '#973d45' , '#005252' , 95 , 36 , '' ] , - \ 'CtrlParrow3' : [ '#005252' , '#002b2b' , 36 , 23 , '' ] , - \ 'CtrlParrow4' : [ '#ffffff' , '#002b2b' , 231 , 23 , '' ] , - \ 'CtrlParrow5' : [ '#005252' , '#003f3f' , 36 , 29 , '' ] } +if get(g:, 'loaded_ctrlp', 0) + let g:airline#themes#luna#ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [ '#ffffff' , '#002b2b' , 231 , 23 , '' ] , + \ [ '#ffffff' , '#005252' , 231 , 36 , '' ] , + \ [ '#ffffff' , '#973d45' , 231 , 95 , '' ] ) +endif diff --git a/autoload/airline/themes/wombat.vim b/autoload/airline/themes/wombat.vim index d01d4411..1e0d67a4 100644 --- a/autoload/airline/themes/wombat.vim +++ b/autoload/airline/themes/wombat.vim @@ -88,12 +88,9 @@ let g:airline#themes#wombat#inactive_modified = { \ 'statusline' : [ '#BCBCBC' , '' , 250 , '' , '' ] } -let g:airline#themes#wombat#ctrlp = { - \ 'CtrlPdark' : [ '#DADADA' , '#242424' , 253 , 234 , '' ] , - \ 'CtrlPlight' : [ '#DADADA' , '#40403C' , 253 , 238 , '' ] , - \ 'CtrlPwhite' : [ '#141413' , '#DADADA' , 232 , 253 , 'bold' ] , - \ 'CtrlParrow1' : [ '#40403C' , '#DADADA' , 238 , 253 , '' ] , - \ 'CtrlParrow2' : [ '#DADADA' , '#40403C' , 253 , 238 , '' ] , - \ 'CtrlParrow3' : [ '#40403C' , '#242424' , 238 , 234 , '' ] , - \ 'CtrlParrow4' : [ '#DADADA' , '#242424' , 253 , 234 , '' ] , - \ 'CtrlParrow5' : [ '#40403C' , '#DADADA' , 238 , 253 , '' ] } +if get(g:, 'loaded_ctrlp', 0) + let g:airline#themes#wombat#ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [ '#DADADA' , '#242424' , 253 , 234 , '' ] , + \ [ '#DADADA' , '#40403C' , 253 , 238 , '' ] , + \ [ '#141413' , '#DADADA' , 232 , 253 , 'bold' ] ) +endif