These are chat archives for Shougo/dein.vim

8th
May 2017
Zhaosheng Pan
@brglng
May 08 2017 02:59
Hi @Shougo , I would like to ask a question about the correct use of dein. Before using dein, I have long used vim-plug, and I put all my plugins at ~/.vim/plug, where ~/.vim is actually a symlink to a synced directory in my Dropbox, so that the whole vim configuration is synced. I continued this habit when started using dein, but I found the configuration if often broken when I have synced between different OS'es, e.g., between Linux and macOS. Then I checked the cache_* file in dein's directory and found dein records absolute paths in its cache, so that the paths are broken between different OS'es, e.g., on Linux it may be /home/username/.vim/dein/.cache and macOS it may be /Users/username/.vim/dein/.cache. I read the doc and it says the typical directory for dein is ~/.cache/dein or ~/.local/share/dein. So does that mean the correct use of dein is to put its directory at some OS-specific path, which should not be synced? As a result, do we have to :call dein#install() or :call dein#update() when setting up the vim configuration for a new computer? Thank you!
Shougo
@Shougo
May 08 2017 03:07
You can set g:dein#cache_directory for it.
Zhaosheng Pan
@brglng
May 08 2017 03:19
Thank you! This solves my problem!
Shougo
@Shougo
May 08 2017 03:26
:-)
Zhaosheng Pan
@brglng
May 08 2017 03:36
I found the caching is really a good feature. When I was using vim-plug, I have to clone several copies for YouCompleteMe and rename them to different names, and pick a specific name on specific OS. I wrote a long function doing all those. With caching, I just need to keep only one copy of the original YouCompleteMe repo at ~/.vim/dein/repo and cache it to ~/.cache/dein, which is a OS-specific path. I don't need to care about the directory names anymore, and the long function is no longer necessary.
Zhaosheng Pan
@brglng
May 08 2017 08:03
It seems Dein does not cache hooks, so the plugins add in .vimrc with hook_post_update dict entry are only correctly installed for the first time. After the vim restarted, dein#load_state() returns 0 and the hooks are not loaded for the plugins, so no hooks will be called for dein#update(). Does that mean I have to call dein#set_hook() after the dein#begin() and dein#end() block?
Shougo
@Shougo
May 08 2017 08:25
The cache hook is only cached if it is String.
You should not use Funcref for hooks.
Zhaosheng Pan
@brglng
May 08 2017 08:31
OK. Thanks.
Zhaosheng Pan
@brglng
May 08 2017 10:40
It seem calling dein#set_hook() after dein#end() does not work, whether or not the hook is a String or a Funcref. But using a String hook in the dictionary of dein#add() works.
Shougo
@Shougo
May 08 2017 11:21
It is cache feature.
Because the cache is generated when dein#end()
You should upload the sample vimrc.
We have not ESP skills
Zhaosheng Pan
@brglng
May 08 2017 11:44
OK. I have solved hook problem by using String for hook_post_update. But there seems another problem that dein#clear_state() does not delete the state file when g:dein#cache_directory is set. Here is my minimal configuration:
let g:dein#install_process_timeout = 3600
let g:dein#cache_directory = $HOME . '/.cache/dein'
set runtimepath+=$HOME/.vim/dein/repos/github.com/Shougo/dein.vim
if dein#load_state($HOME . '/.cache/dein')
  call dein#begin($HOME . '/.vim/dein')
  call dein#add($HOME . '/.vim/dein/repos/github.com/Shougo/dein.vim')
  ...
  call dein#end()
  call dein#save_state()
endif
Shougo
@Shougo
May 08 2017 11:55
OK.
I will check it.
Please create new issue for the problem
Zhaosheng Pan
@brglng
May 08 2017 11:56
OK.