Skip to content

Instantly share code, notes, and snippets.

@idbrii
Forked from kien/gist:1610859
Created July 8, 2012 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save idbrii/3069527 to your computer and use it in GitHub Desktop.
Save idbrii/3069527 to your computer and use it in GitHub Desktop.
Custom statusline example
" File: after/plugin/ctrlp.vim
" Description: Custom statusline example
" Make sure ctrlp is installed and loaded
if !exists('g:loaded_ctrlp') || ( exists('g:loaded_ctrlp') && !g:loaded_ctrlp )
fini
en
" ctrlp only looks for this
let g:ctrlp_status_func = {
\ 'main': 'CtrlP_Statusline_Main',
\ 'prog': 'CtrlP_Statusline_Progress',
\ }
" This part's just an example that recreates the default styling based on
" commit 2826589:
" CtrlP_Statusline_Main and CtrlP_Statusline_Progress both must return a full statusline
" and are accessible globally.
" Main statusline is the same as default, but without the prev/next modes.
function! CtrlP_Statusline_Main(focus, byfname, regexp, prv, item, nxt, marked)
let marked = a:marked
let dyncwd = getcwd()
let item = '%#CtrlPMode1# '.a:item.' %*'
let focus = '%#CtrlPMode2# '.a:focus.' %*'
let byfname = '%#CtrlPMode1# '.a:byfname.' %*'
let regex = a:regexp ? '%#CtrlPMode2# regex %*' : ''
let slider = ' <'.a:prv.'>={'.a:item.'}=<'.a:nxt.'>'
let dir = ' %=%<%#CtrlPMode2# '.dyncwd.' %*'
let stl = focus.byfname.regex.slider.marked.dir
return stl
endfunction
" Progress statusline is the same as CtrlP default.
function! CtrlP_Statusline_Progress(enum)
let dyncwd = getcwd()
let txt = a:0 ? '(press ctrl-c to abort)' : ''
let stl = '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# '.dyncwd.' %*'
return stl
endfunction
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
@idbrii
Copy link
Author

idbrii commented Jul 8, 2012

I've changed this to directly copy the code from autoload/ctrlp.vim and use some intermediate variables for things that aren't available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment