Extensions with arguments? #277

tmcw opened this Issue Sep 12, 2012 · 4 comments

2 participants


I'd like to build an extension for ctrlp that works with csearch and calls the csearch binary with a search term. It should be fast enough to work in realtime. Basically what I'd be looking for is to do an extension that calls a binary repeatedly - and I can't seem to find an example that does that, like the ctrlp core does with user_command.

Is this possible with the extension API? Thanks!


Would the g:ctrlp_match_func option work for what you need? Here's an example from a different script:

let g:ctrlp_match_func = { 'match': 'MatchFunc' }
let g:path_to_binary = "/path/to/binary"

function! MatchFunc(items, str, limit, mmode, ispath, crfile, regex)
  " Create a cache file
  let cachefile = ctrlp#utils#cachedir().'/custom.cache'
  if !( filereadable(cachefile) && a:items == readfile(cachefile) )
    call writefile(a:items, cachefile)
  if !filereadable(cachefile)
    return []

  let cmd = g:path_to_binary.' --limit '.a:limit.' --manifest '.cachefile.' '.a:str
  return split(system(cmd), "\n")

You can check the help for the details on the arguments.


Sorry, I might just be being dim: this replaces the existing ctrlp_match_func, right? I'm looking to add another mode that searches in files, while maintaining the same behavior for ctrlp w/ directories & filenames.


Yeah, it's an option to replace the built-in matching function.

So this isn't possible, yet, I think. With an extension, ctrlp still does all the matching and filtering. I might do something about this in the future, but it probably won't be anytime soon.


Okay - no problem. Thanks for the excellent plugin!

@tmcw tmcw closed this Jan 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment