ctrlp.vim
ctrlp.vim copied to clipboard
How to prevent ctrlp from indexing $HOME
I am not sure where to go with this question, but if I open up vim in $HOME and hit ctrl-p (because I thought i was in a different working directory) it will take forever to index and pretty much hang. I want to be able to tell ctrl-p to either not run when the working directory is $HOME or to ignore $HOME (but still allow for $HOME/projects/...). What's the best way to handle this?
Hi, I had a similar problem. If i'm in a project, do a quick :e of ~/.vimrc, and then hit ctrl-p, blammo. Everything locks up for 30 seconds.
Removing 'a' from g:ctrlp_working_path_mode
fixed it for me: https://github.com/bronson/dotfiles/commit/4126863544da4cf20c016f728ed3586dda617f44
This doesn't help when you start vim in your homedir, alas. I just remember not to do that...
Quite a primitive workaround:
nnoremap <LEADER>f :call RunCtrlP()<CR>
fun! RunCtrlP()
lcd %:p:h
if (getcwd() == $HOME)
echo "Can't run in \$HOME"
return
endif
CtrlP
endfunc
Note that I'm changing the working directory to that containing the current file. It fits my workflow but may not necessarily fit yours.
I use ag
as my ctrlp user command
if executable('ag')
let g:ctrlp_user_command = 'ag %s --nocolor -g ""'
endif
and then any top-level directories in my home that don't usually contain text files go in my .agignore
.
Same problem, how to cancel indexing?
I just wanted to edit some quick file and then... Ctrl+P and BUM! only exit is force closing VIM
Inspired by @aandrieiev 's answer. This will also work:
let g:ctrlp_user_command = '[ $PWD == $HOME ] && echo "In HOME Directory" || ag %s ""'
You can replace ag %s ""
with any file listing command to run, e.g. with find: find %s
.
I can get out of indexing easily by pressing Ctrl+C one or two times.