When calling CtrlP for the first time it cause quite a delay to build the cache. Is there a way to run it in the background so I can continue doing stuff in vim?
Asked
Active
Viewed 950 times
1
-
5No, Vim doesn't do asynchronous execution. Start Vim from the root of your project, not from your `$HOME`. – romainl Sep 11 '15 at 06:59
-
1@romainl That might need to be updated for Vim 8. – Olle Härstedt Jul 21 '16 at 20:45
-
@romainl, is there a way to build the cache continuously? it seems if I havent build the cache in a while, ctrlp will try to build the cache the first time I boot up ctrlp, and it ends up taking a while.. I am using vim8 which has async feature.. – alpha_989 Apr 05 '18 at 16:18
-
@alpha_989, I've stopped using that plugin a long time ago. – romainl Apr 05 '18 at 19:13
2 Answers
11
If you need to speed up indexing of CtrlP, you can use ag to grep files, exclude some folders and files from indexing, and set cache location.
To do that, put these lines in your .vimrc:
let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp'
let g:ctrlp_user_command = 'ag %s -i --nocolor --nogroup --hidden
\ --ignore .git
\ --ignore .svn
\ --ignore .hg
\ --ignore .DS_Store
\ --ignore "**/*.pyc"
\ -g ""'

ryuichiro
- 3,765
- 1
- 16
- 21
3
You cannot do that, in fact, vim isn't multi-threaded.
You can look over for NeoVim which is multi-threaded.
Alternativly, you could use the Unite plugin and the file_rec/async
command :
Note: with large projects this may cause some performance problems. Normally it is recommended to use |unite-source-file_rec/async| source, which requires |vimproc|.
-
thank you for your response. I have installed NeoVim. How can I do it with NeoVim? When I run CtrlP it stucks till it finishes the indexation like in Vim. – whitesiroi Sep 11 '15 at 08:34
-
2CtrlP has been abandoned for a few years, now, and thus doesn't benefit from the new features in neovim. – romainl Sep 11 '15 at 09:00