vim-airline/autoload/airline/extensions/ctrlp.vim

75 lines
2.8 KiB
VimL
Raw Normal View History

" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
2013-08-03 01:56:12 +08:00
if !get(g:, 'loaded_ctrlp', 0)
finish
endif
let s:color_template = get(g:, 'airline#extensions#ctrlp#color_template', 'insert')
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
function! airline#extensions#ctrlp#load_theme(palette)
if exists('a:palette.ctrlp')
let theme = a:palette.ctrlp
2013-07-27 01:21:43 +08:00
else
let s:color_template = has_key(a:palette, s:color_template) ? s:color_template : 'insert'
let theme = airline#extensions#ctrlp#generate_color_map(
\ a:palette[s:color_template]['airline_c'],
\ a:palette[s:color_template]['airline_b'],
\ a:palette[s:color_template]['airline_a'])
2013-07-27 01:21:43 +08:00
endif
for key in keys(theme)
2013-08-17 20:50:07 +08:00
call airline#highlighter#exec(key, theme[key])
2013-07-27 01:21:43 +08:00
endfor
2013-07-06 16:20:20 +08:00
endfunction
" Arguments: focus, byfname, s:regexp, prv, item, nxt, marked
2013-07-07 20:41:36 +08:00
function! airline#extensions#ctrlp#ctrlp_airline(...)
2013-07-06 16:20:20 +08: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.(g:airline_symbols.space)
2013-07-06 16:20:20 +08:00
let focus = '%=%<%#CtrlPdark# '.a:1.' %*'
let byfname = '%#CtrlParrow3#'.g:airline_right_alt_sep.'%#CtrlPdark# '.a:2.' %*'
2013-07-06 16:20:20 +08:00
let dir = '%#CtrlParrow3#'.g:airline_right_sep.'%#CtrlPlight# '.getcwd().' %*'
if get(g:, 'airline#extensions#ctrlp#show_adjacent_modes', 1)
let modes = prv.item.nxt
else
let modes = item
endif
return regex.modes.marked.focus.byfname.dir
2013-07-06 16:20:20 +08:00
endfunction
" Argument: len
2013-07-07 20:41:36 +08:00
function! airline#extensions#ctrlp#ctrlp_airline_status(...)
let len = '%#CtrlPdark# '.a:1
let dir = '%=%<%#CtrlParrow3#'.g:airline_right_sep.'%#CtrlPlight# '.getcwd().' %*'
2013-07-06 16:20:20 +08:00
return len.dir
endfunction
function! airline#extensions#ctrlp#apply(...)
" disable statusline overwrite if ctrlp already did it
return match(&statusline, 'CtrlPlight') >= 0 ? -1 : 0
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',
\ }
call a:ext.add_statusline_func('airline#extensions#ctrlp#apply')
call a:ext.add_theme_func('airline#extensions#ctrlp#load_theme')
endfunction