0

I am trying to write my own CtrlP extension.

The document shows that, we have to set g:ctrlp_extensions as follow to make our extension working.

let g:ctrlp_extensions = ['extensionname']

But it seems these two extension:ctrlp-funky, ctrlp-extensions.vim can still work without setting g:ctrlp_extensions(I failed to find this variable in the souce files of this two extension by using grep -rn "g:ctrlp_extensions" *).

So my question is:

  1. can we extend CtrlP without setting g:ctrlp_extensions
  2. if so, how can we do that
guorongfei
  • 309
  • 2
  • 10

1 Answers1

1

After i read the code carfully, i found out that i need to modify g:ctrlp_ext_vars for this purpose like this.

First define you own ctrlp_extension_var:

let s:ctrlp_extension_var = {
        \ 'init': 'xxx',
        \ 'accept': 'xxx',
        \ 'lname': 'xxx',
        \ 'sname': 'xxx',
        \ }

Second, set or add your ctrl_extension_var to g:ctrlp_ext_vars:

if exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
  let g:ctrlp_ext_vars = add(g:ctrlp_ext_vars, s:ctrlp_extension_var)
else
  let g:ctrlp_ext_vars = [s:ctrlp_extension_var]
endif
guorongfei
  • 309
  • 2
  • 10