Open drogus opened 9 years ago
It turns out that the problem was caused by .gitignore
entries. The following works correctly:
node_modules
bower_components
But this form fails:
/node_modules
/bower_components
I'm still not sure if this is a bug in ag or in ctrlp, because when run in the project's root dir ag returns correct results (no node_modules etc.)
I suspect it to be ag
. Which version do you use? Here it's 0.19.2 and it correctly recognizes the absolute paths /dir
with respect to the location of .gitignore
. However, before it was 0.28
and this was not the case.
I'm also get the same weird behavior with a custom command using ag.
With /_build
in my .gitignore ag -g ''
does not list anything from the directory.
Using :CtrlP
inside (neo)vim shows the same output as ag, but when I run ctrlp for a second time entries from _build are shown, and ctrlp shows that it's caching even though I have g:ctrlp_use_caching = 0
.
Changing /_build
to _build
fixes this :confused:
I have a problem that's a bit related to this issue here. I also use ag for searching with ctrlp and everything works as expected when I'm using regular vim. But when I'm using the same configuration with neovim I get strange results. Default ag settings and and .agignore are completely ignored and ctrlp finds everything, even in the folders I do not want it too. I'm guessing with neovim, ctrlp doesn't use ag but the default search engine? I know this is a bit of a non-issue seeing as neovim is still in development but I still wanted to get it out there. Maybe other people will have the same problem as me.
My configuration for ctrlp is this: let g:ctrlp_working_path_mode = 'ra' let g:ctrlp_user_command = 'ag %s -l --hidden --nocolor -g ""'
Running into this issue as well.
ag
works great when manually run in the directory.
ctrlp
along with ag
as custom command lists .gitignore
files as well.
I simply could not solve this so reverted to OP's git ls-files
solution
@Numkil @pgilad did you manage to solve this issue?
I'm running into it as well
I didn't
I actually switched over to this maintained fork of ctrlp. It works there. https://github.com/ctrlpvim/ctrlp.vim
@stevedomin @pgilad Hope this helps for you guys
Combined with the fork @Numkil mentions, the following seems to work for me:
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
nnoremap <silent> t :CtrlP<cr>
let g:ctrlp_match_window = 'bottom,order:ttb'
let g:ctrlp_switch_buffer = 0
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_use_caching = 0
let g:ctrlp_user_command = ['ag %s --files-with-matches -g ""']
let g:ctrlp_user_command += ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
endif
(To be honest not super sure if it actually ends up using ag properly or not)
@zilman , what does the %s
mean here?
Also I have found that :CtrlpTag
tends to be very slow.. Is there any way to speed it up?
@drogus My config like this and it's work as expected.
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
I use a custom
g:ctrlp_user_command
and it includes results that shouldn't be there. I'm not sure if this is a ctrlp's fault, but I'm also not sure how to debug it.I use the following:
Running it in terminal returns about 500 files for the project I'm working on. When I use ctrlp with such a command, however, I get hits that aren't included when running the command, for example
node_modules
directory, which is in.gitignore
and isn't listed when I run theag
command manually.Using
g:ctrlp_custom_ignore
andgit ls-files
works correctly:I also
:echo
ed theg:ctrlp_user_command
and it contains the value that I expect, so it's rather not a problem with setting it improperly.Any tips on how to debug what's going on?