This is the most automatic solution that will work in different windows and tabs that have their own lcd
(local current directory).
Since Vimrc doensn't have the concept of setting exclude variables per-window or per-tab, you have to reset the exclude variables each time your run FufFile
or related functions.
Put this in your .vimrc
:
" FuzzyFinder
" -----------------------------------------------------------------------------
function! FufSetIgnore()
let ignorefiles = [ $HOME . "/.gitignore", ".gitignore" ]
let exclude_vcs = '\.(hg|git|bzr|svn|cvs)'
let ignore = '\v\~$'
for ignorefile in ignorefiles
if filereadable(ignorefile)
for line in readfile(ignorefile)
if match(line, '^\s*$') == -1 && match(line, '^#') == -1
let line = substitute(line, '^/', '', '')
let line = substitute(line, '\.', '\\.', 'g')
let line = substitute(line, '\*', '.*', 'g')
let ignore .= '|^' . line
endif
endfor
endif
let ignore .= '|^' . exclude_vcs
let g:fuf_coveragefile_exclude = ignore
let g:fuf_file_exclude = ignore
let g:fuf_dir_exclude = ignore
endfor
endfunction
# Bonus: My custom key mappings for FuzzyFinder
# Calls the function to set the exclude variables, then runs FuzzyFinder
nn <Tab> :call FufSetIgnore() <BAR> :FufFile<CR>
nn <S-Tab> :call FufSetIgnore() <BAR> :FufFile **/<CR>
nn <F3> :call FufSetIgnore() <BAR> :FufFile **/<CR>