burke / matcher

[abandoned] Intelligently searches through a list of file names for the one you were probably looking for.
BSD 2-Clause "Simplified" License
141 stars 9 forks source link

Matcher

This is a standalone library that does the same fuzzy-find matching as Command-T.vim.

Installation

$ make
# move `matcher` somewhere useful
$ make install
# make install will install it to /usr/local/bin.

Usage

Matcher searches for a string in a list of filenames, and returns the ones it thinks you are most likely referring to. It works exactly like fuzzy-finder, Command-T, and so on.

Usage:

$ matcher [options] <search>

Options:

Examples

$ matcher --limit 20 --no-dotfiles --manifest filelist.txt customer.rb
$ find . | matcher order

Using with CtrlP.vim

let g:path_to_matcher = "/path/to/matcher"

let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files . -co --exclude-standard']

let g:ctrlp_match_func = { 'match': 'GoodMatch' }

function! GoodMatch(items, str, limit, mmode, ispath, crfile, regex)

  " Create a cache file if not yet exists
  let cachefile = ctrlp#utils#cachedir().'/matcher.cache'
  if !( filereadable(cachefile) && a:items == readfile(cachefile) )
    call writefile(a:items, cachefile)
  endif
  if !filereadable(cachefile)
    return []
  endif

  " a:mmode is currently ignored. In the future, we should probably do
  " something about that. the matcher behaves like "full-line".
  let cmd = g:path_to_matcher.' --limit '.a:limit.' --manifest '.cachefile.' '
  if !( exists('g:ctrlp_dotfiles') && g:ctrlp_dotfiles )
    let cmd = cmd.'--no-dotfiles '
  endif
  let cmd = cmd.a:str

  return split(system(cmd), "\n")

endfunction

Bugs

Contributing