Skip to content

Instantly share code, notes, and snippets.

@kien
Created January 14, 2012 09:49
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kien/1610859 to your computer and use it in GitHub Desktop.
Save kien/1610859 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_1',
\ 'prog': 'CtrlP_Statusline_2',
\ }
" This part's just an example that recreates the default styling:
" CtrlP_Statusline_1 and CtrlP_Statusline_2 both must return a full statusline
" and are accessible globally.
" Arguments: focus, byfname, s:regexp, prv, item, nxt, marked
" a:1 a:2 a:3 a:4 a:5 a:6 a:7
fu! CtrlP_Statusline_1(...)
let focus = '%#LineNr# '.a:1.' %*'
let byfname = '%#Character# '.a:2.' %*'
let regex = a:3 ? '%#LineNr# regex %*' : ''
let prv = ' <'.a:4.'>='
let item = '{%#Character# '.a:5.' %*}'
let nxt = '=<'.a:6.'>'
let marked = ' '.a:7.' '
let dir = ' %=%<%#LineNr# '.getcwd().' %*'
" Return the full statusline
retu focus.byfname.regex.prv.item.nxt.marked.dir
endf
" Argument: len
" a:1
fu! CtrlP_Statusline_2(...)
let len = '%#Function# '.a:1.' %*'
let dir = ' %=%<%#LineNr# '.getcwd().' %*'
" Return the full statusline
retu len.dir
endf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment