2016-01-14 21:38:38 -05:00
|
|
|
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
2013-08-21 11:14:12 -04:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
2013-08-02 13:56:12 -04:00
|
|
|
|
2013-09-10 11:37:25 -04:00
|
|
|
if !get(g:, 'loaded_ctrlp', 0)
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2013-08-20 16:30:46 -04:00
|
|
|
let s:color_template = get(g:, 'airline#extensions#ctrlp#color_template', 'insert')
|
|
|
|
|
2013-07-27 16:16:13 -04: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-09-01 19:39:06 -04:00
|
|
|
function! airline#extensions#ctrlp#load_theme(palette)
|
|
|
|
if exists('a:palette.ctrlp')
|
|
|
|
let theme = a:palette.ctrlp
|
2013-07-26 13:21:43 -04:00
|
|
|
else
|
2013-09-01 19:39:06 -04:00
|
|
|
let s:color_template = has_key(a:palette, s:color_template) ? s:color_template : 'insert'
|
2013-07-27 16:16:13 -04:00
|
|
|
let theme = airline#extensions#ctrlp#generate_color_map(
|
2013-09-01 19:39:06 -04:00
|
|
|
\ a:palette[s:color_template]['airline_c'],
|
|
|
|
\ a:palette[s:color_template]['airline_b'],
|
|
|
|
\ a:palette[s:color_template]['airline_a'])
|
2013-07-26 13:21:43 -04:00
|
|
|
endif
|
|
|
|
for key in keys(theme)
|
2013-08-17 08:50:07 -04:00
|
|
|
call airline#highlighter#exec(key, theme[key])
|
2013-07-26 13:21:43 -04:00
|
|
|
endfor
|
2013-07-06 04:20:20 -04:00
|
|
|
endfunction
|
|
|
|
|
2013-10-01 21:23:17 -04:00
|
|
|
" Arguments: focus, byfname, regexp, prv, item, nxt, marked
|
2013-07-07 08:41:36 -04:00
|
|
|
function! airline#extensions#ctrlp#ctrlp_airline(...)
|
2013-10-01 21:23:17 -04:00
|
|
|
let b = airline#builder#new({'active': 1})
|
2014-11-20 08:23:25 -05:00
|
|
|
if a:2 == 'file'
|
|
|
|
call b.add_section_spaced('CtrlPlight', 'by fname')
|
|
|
|
endif
|
2013-10-01 21:23:17 -04:00
|
|
|
if a:3
|
|
|
|
call b.add_section_spaced('CtrlPlight', 'regex')
|
|
|
|
endif
|
2013-09-19 11:04:37 -04:00
|
|
|
if get(g:, 'airline#extensions#ctrlp#show_adjacent_modes', 1)
|
2013-10-01 21:23:17 -04:00
|
|
|
call b.add_section_spaced('CtrlPlight', a:4)
|
|
|
|
call b.add_section_spaced('CtrlPwhite', a:5)
|
|
|
|
call b.add_section_spaced('CtrlPlight', a:6)
|
2013-09-19 11:04:37 -04:00
|
|
|
else
|
2013-10-01 21:23:17 -04:00
|
|
|
call b.add_section_spaced('CtrlPwhite', a:5)
|
2013-09-19 11:04:37 -04:00
|
|
|
endif
|
2013-10-01 21:23:17 -04:00
|
|
|
call b.add_section_spaced('CtrlPdark', a:7)
|
|
|
|
call b.split()
|
2014-11-22 11:52:54 -05:00
|
|
|
call b.add_section_spaced('CtrlPdark', a:1)
|
2013-10-01 21:23:17 -04:00
|
|
|
call b.add_section_spaced('CtrlPdark', a:2)
|
|
|
|
call b.add_section_spaced('CtrlPlight', '%{getcwd()}')
|
|
|
|
return b.build()
|
2013-07-06 04:20:20 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Argument: len
|
2013-07-07 08:41:36 -04:00
|
|
|
function! airline#extensions#ctrlp#ctrlp_airline_status(...)
|
2013-07-27 17:54:05 -04:00
|
|
|
let len = '%#CtrlPdark# '.a:1
|
|
|
|
let dir = '%=%<%#CtrlParrow3#'.g:airline_right_sep.'%#CtrlPlight# '.getcwd().' %*'
|
2013-07-06 04:20:20 -04:00
|
|
|
return len.dir
|
|
|
|
endfunction
|
2013-08-05 23:34:45 -04:00
|
|
|
|
2013-08-21 23:25:22 -04:00
|
|
|
function! airline#extensions#ctrlp#apply(...)
|
|
|
|
" disable statusline overwrite if ctrlp already did it
|
2013-10-01 21:23:17 -04:00
|
|
|
return match(&statusline, 'CtrlPwhite') >= 0 ? -1 : 0
|
2013-08-05 23:34:45 -04: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 17:22:20 -04:00
|
|
|
call a:ext.add_statusline_func('airline#extensions#ctrlp#apply')
|
2013-09-01 19:39:06 -04:00
|
|
|
call a:ext.add_theme_func('airline#extensions#ctrlp#load_theme')
|
2013-08-05 23:34:45 -04:00
|
|
|
endfunction
|
2013-08-21 11:14:12 -04:00
|
|
|
|