Skip to content

Commit

Permalink
Always apply g:fuzzyy_files_exclude_{file,dir}
Browse files Browse the repository at this point in the history
This makes sense to me, the defaults are now set to values that you
probably always want to ignore, vim swap files, tags files, common
version control directories, and users may want to always exclude some
files or directories without adding to gitignore or other ignore files.

For example, I might like to add tags.* to this, for Vim gutentags.
Sure, I could add to a "global" ignore file, but that won't necessarily
work with --no-ignore-parent, and maybe I want --no-ignore-parent. Also,
fd and rg don't follow include directives in git config, so if you set a
"global" gitignore using core.excludesFile from a config file included
from your global gitconfig it doesn't work as expected with fd and rg.
  • Loading branch information
mmrwoods committed Nov 29, 2024
1 parent e6df60d commit 8f6a510
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ let g:enable_fuzzyy_keymaps = 0
" Default to 1
let g:fuzzyy_files_respect_gitignore = 0
" FuzzyFiles will exclude the files/directory in these two lists
" only work when
" 1. g:fuzzyy_files_respect_gitignore = 0
" 2. or fd not installed and not in git repository
" FuzzyFiles will always exclude the files/directory in these two lists
" The following is the default
let g:fuzzyy_files_exclude_file = ['*.swp', 'tags']
let g:fuzzyy_files_exclude_dir = ['.git', '.hg', '.svn']
Expand Down
18 changes: 8 additions & 10 deletions autoload/utils/cmdbuilder.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,31 @@ var dir_exclude = exists('g:fuzzyy_files_exclude_dir')
g:fuzzyy_files_exclude_dir : dir_exclude_default

export def Build_fd(): string
if respect_gitignore
return 'fd --type f -H -E .git'
var result = 'fd --type f -H'
if ! respect_gitignore
result ..= ' --no-ignore'
endif
var dir_list_parsed = reduce(dir_exclude,
(acc, dir) => acc .. "-E " .. dir .. " ", "")

var file_list_parsed = reduce(file_exclude,
(acc, file) => acc .. "-E " .. file .. " ", "")

var result = "fd --type f -H -I " .. dir_list_parsed .. file_list_parsed

return result
return result .. ' ' .. dir_list_parsed .. file_list_parsed
enddef

export def Build_rg(): string
if respect_gitignore
return 'rg --files -H -g !.git'
var result = 'rg --files -H'
if ! respect_gitignore
result ..= ' --no-ignore'
endif
var dir_list_parsed = reduce(dir_exclude,
(acc, dir) => acc .. "-g !" .. dir .. " ", "")

var file_list_parsed = reduce(file_exclude,
(acc, file) => acc .. "-g !" .. file .. " ", "")

var result = "rg --files -H --no-ignore " .. dir_list_parsed .. file_list_parsed

return result
return result .. ' ' .. dir_list_parsed .. file_list_parsed
enddef

export def Build_find(): string
Expand Down

0 comments on commit 8f6a510

Please sign in to comment.