Search code examples
fzfripgrepvim-fzf

.gitignore node_modules/ not working for fd and ripgrep


I'm trying to setup fzf.vim for vim on windows 10.

You can use an alternative find command like ripgrep or fd which is supposed to respect .gitignore.

My .gitignore file has this line, which is working fine for git commits, etc.:

node_modules/

My dir structure is

/working directory
.gitignore file
.git  dir
/node_modules dir

When I run

fd --type f

or

rg --files

It lists all files in node_modules.

I feel like this may be a windows problem.

How can I get these programs to use .gitignore to ignore node_modules?


Solution

  • Turns out, I was using a project where the git repo had not yet been initialized. So I had a .gitignore, but did not have a .git folder. And by default ripgrep needs it to be an actual git repository to utilize the .gitiginore folder. My solution was to use the following flag -

    --no-require-git

    More info here