Shougo / dein.vim

:zap: Dark powered Vim/Neovim plugin manager
MIT License
3.43k stars 198 forks source link

Q: hook_post_source and autocmd VimEnter #390

Closed hasufell closed 4 years ago

hasufell commented 4 years ago

I want to define this:

hook_post_source = '''
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
'''
[[plugins]]
repo = 'scrooloose/nerdtree'

It isn't working (netrw is still opend instead of NERDTree). This approach used to work with vim-plug. I also tried adding autocmd VimEnter * call dein#call_hook('post_source') to my vimrc, but that didn't do the trick either.

Shougo commented 4 years ago
[[plugins]]
repo = 'scrooloose/nerdtree'
hook_add = '''
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
'''

You need to know when hooks are executed.

I also tried adding autocmd VimEnter * call dein#call_hook('post_source') to my vimrc, but that didn't do the trick either.

this is wrong. Because, your VimEnter autocmd is defined in VimEnter. When it is executed? never.