Everyone loves Unite's file_rec/async file searcher, but it can be slow and unhelpful if it's not tuned properly.

The first thing that can be done to make Unite's file search faster is to use ag instead of the default, find. Unite is pretty smart, and it will use ag if it's available, so a simple brew install ag will get you rolling on Mac (installation instructions are on Github for other platforms).

By default, ag ignores files which are in your project's .gitignore (or .hgignore), but that behavior has been disabled in Unite. Luckily, we can reenable it pretty easily by changing the command Unite uses to search files for file_rec/async by doing something like:

let g:unite_source_rec_async_command= 'ag --nocolor --nogroup --hidden -g ""'

in vimrc. You may want to wrap this with a if executable('ag') if you're trying to keep your config portable.

After making this change, you may see inconsistent results in your Unite buffer because of the Unite cache. To clear the cache, <C-l> within a unite buffer.

Hopefully this speeds up your filematching!