2013-08-21 15:14:12 +00:00
|
|
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
|
|
|
" vim: et ts=2 sts=2 sw=2
|
2013-08-02 17:56:12 +00:00
|
|
|
|
2013-08-20 20:30:46 +00:00
|
|
|
let s:color_template = get(g:, 'airline#extensions#ctrlp#color_template', 'insert')
|
|
|
|
|
2013-07-27 20:16:13 +00:00
|
|
|
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] , '' ] ,
|
|
|
|
\ }
|
|
|
|
endfunction
|
|
|
|
|
2013-07-27 14:02:43 +00:00
|
|
|
function! airline#extensions#ctrlp#load_theme()
|
2013-08-18 00:59:49 +00:00
|
|
|
if exists('g:airline#themes#{g:airline_theme}#palette.ctrlp')
|
|
|
|
let theme = g:airline#themes#{g:airline_theme}#palette.ctrlp
|
2013-07-26 17:21:43 +00:00
|
|
|
else
|
2013-08-20 20:30:46 +00:00
|
|
|
let s:color_template = has_key(g:airline#themes#{g:airline_theme}#palette, s:color_template) ? s:color_template : 'insert'
|
2013-07-27 20:16:13 +00:00
|
|
|
let theme = airline#extensions#ctrlp#generate_color_map(
|
2013-08-20 20:30:46 +00:00
|
|
|
\ 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'])
|
2013-07-26 17:21:43 +00:00
|
|
|
endif
|
|
|
|
for key in keys(theme)
|
2013-08-17 12:50:07 +00:00
|
|
|
call airline#highlighter#exec(key, theme[key])
|
2013-07-26 17:21:43 +00:00
|
|
|
endfor
|
2013-07-06 08:20:20 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Arguments: focus, byfname, s:regexp, prv, item, nxt, marked
|
2013-07-07 12:41:36 +00:00
|
|
|
function! airline#extensions#ctrlp#ctrlp_airline(...)
|
2013-07-06 08:20:20 +00:00
|
|
|
let regex = a:3 ? '%#CtrlPlight# regex %*' : ''
|
|
|
|
let prv = '%#CtrlPlight# '.a:4.' %#Ctrlparrow1#'.g:airline_left_sep
|
|
|
|
let item = '%#CtrlPwhite# '.a:5.' %#CtrlParrow2#'.g:airline_left_sep
|
|
|
|
let nxt = '%#CtrlPlight# '.a:6.' %#CtrlParrow3#'.g:airline_left_sep
|
|
|
|
let marked = '%#CtrlPdark# '.a:7.' '
|
|
|
|
let focus = '%=%<%#CtrlPdark# '.a:1.' %*'
|
2013-07-27 21:54:05 +00:00
|
|
|
let byfname = '%#CtrlParrow3#'.g:airline_right_alt_sep.'%#CtrlPdark# '.a:2.' %*'
|
2013-07-06 08:20:20 +00:00
|
|
|
let dir = '%#CtrlParrow3#'.g:airline_right_sep.'%#CtrlPlight# '.getcwd().' %*'
|
|
|
|
return regex.prv.item.nxt.marked.focus.byfname.dir
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Argument: len
|
2013-07-07 12:41:36 +00:00
|
|
|
function! airline#extensions#ctrlp#ctrlp_airline_status(...)
|
2013-07-27 21:54:05 +00:00
|
|
|
let len = '%#CtrlPdark# '.a:1
|
|
|
|
let dir = '%=%<%#CtrlParrow3#'.g:airline_right_sep.'%#CtrlPlight# '.getcwd().' %*'
|
2013-07-06 08:20:20 +00:00
|
|
|
return len.dir
|
|
|
|
endfunction
|
2013-08-06 03:34:45 +00:00
|
|
|
|
2013-08-22 03:25:22 +00:00
|
|
|
function! airline#extensions#ctrlp#apply(...)
|
|
|
|
" disable statusline overwrite if ctrlp already did it
|
|
|
|
return match(&statusline, 'CtrlPlight') >= 0 ? -1 : 0
|
2013-08-06 03:34:45 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#extensions#ctrlp#init(ext)
|
|
|
|
let g:ctrlp_status_func = {
|
|
|
|
\ 'main': 'airline#extensions#ctrlp#ctrlp_airline',
|
|
|
|
\ 'prog': 'airline#extensions#ctrlp#ctrlp_airline_status',
|
|
|
|
\ }
|
2013-08-23 21:22:20 +00:00
|
|
|
call a:ext.add_statusline_func('airline#extensions#ctrlp#apply')
|
2013-08-06 03:34:45 +00:00
|
|
|
endfunction
|
2013-08-21 15:14:12 +00:00
|
|
|
|