CtrlP:忽略git仓库中子目录中的文件

oct*_*ref 9 git vim gitignore ctrlp

对于我的回购,假设它被称为 top

top\
  .gitignore
  foo\
  bar\
Run Code Online (Sandbox Code Playgroud)

我希望CtrlP列出文件

  1. foo\
  2. 顶部\中.gitignore定义不被忽略

如果我进入top\foo\,并从那里打开vim,1会满意而不是2.
如果我打开vim top\,2会满意但不是1.

我如何实现1和2?

我尝试了这个gitignore vim脚本,但它只gitignore在我在repo的根文件夹中打开vim时解析,所以我不能同时做1和2.
同样的let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""',ag不试图去repo root并从那里读gitignore.
设置g:ctrlp_working_path_moder让CtrlP .gitignore在顶级文件夹中受到尊重,但是top\Ctrl 下会列出所有内容.我只想要文件foo\.

谢谢.

jth*_*ill 12

它的主页看起来你可以使用

let g:ctrlp_user_command = [
    \ '.git', 'cd %s && git ls-files . -co --exclude-standard',
    \ 'find %s -type f'
    \ ]
Run Code Online (Sandbox Code Playgroud)

这将有利于尊重所有git的忽略模式处理,而不仅仅是顶级正面.gitiginore模式.