Selecta on Vim using 'wildignore'
One plugin that I've used a lot was Command-T, fuzzy search files is a big productivity boost when you are a developer. But one of the problems with Command-T is that it requires compilation, is not something that you just load and you are done. Recently Gary Bernhardt created the Selecta fuzzy finder, which can be used for anything that spits output to standard out and reads from standard in (which means almost every Unix command known).
Using Selecta on Vim is just a read the
docs away, Selecta is
input agnostic in a sense and actually doesn't known anything about Vim. If you
check out the Vim function you will see that it just gets the output of a
command. The only thing I missed right away was Command-T used to respect my
wildignore option on Vim, so I did a small function to recreate the
command based on my
wildignore. Here it goes:
function! FindWithWildignore() let excluding="" for entry in split(&wildignore,",") let excluding.= (match(entry,'*/*') ? " ! -ipath \'" : " ! -iname \'") . entry . "\' " endfor return "find * -type f \\\( " . excluding . " \\\)" endfunction
The thing to note is that I use
-iname depending on the entry
because I might ignore files or a full directory on
wildignore. Plug this into
SelectaCommand and now settings on
wildignore will be excluded from
your choices, like so.
nnoremap <leader>t :call SelectaCommand(FindWithWildignore(), "", ":e")<cr>
You can check out the full