yannickperrenet / dotfiles

💛 My dotfiles.
https://github.com/yannickperrenet/iscripts
MIT License
3 stars 0 forks source link

Vim plugin CtrlP to respect .gitignore files #13

Closed yannickperrenet closed 3 years ago

yannickperrenet commented 3 years ago

Either the .gitignore file in the directory in which vim is opened, or if vim is opened in a subdirectory it should search for the project level .gitignore

yannickperrenet commented 3 years ago

From the ctrlp.txt

Q: Why can't CtrlP support .gitignore or .hgignore natively? A: Those files look at first like they may contain all the patterns you'd want to exclude from CtrlP already. However, more often than not, there are some differences. Those files list patterns that should not be included in source-control. This includes things you want to ignore, but also things you may not want to: local settings, external packages and dependencies, etc. The author felt the trouble of supporting various syntaxes was too much compared to just copy/pasting a few lines.

yannickperrenet commented 3 years ago

Taking a look at ctrlp_user_command in ctrlp.txt yielded the following solution:

let g:ctrlp_user_command = {
\ 'types': {
  \ 1: ['.git', 'git ls-files'],
  \ },
\ 'fallback': 'fd --type file'
\ }

Also the use of fd in the fallback is faster than Vim's globpath