0

I'm using denite plugin and I have some intialization for it.

call denite#custom#source(
    \ 'file_rec', 'matchers', ['matcher_fuzzy', 'matcher_project_files'])
call denite#custom#var('file_rec/git', 'command', ['git', 'ls-files', '-co', '--exclude-standard'])

Since I moved from external package manager into vim packages I moved this into a function that is executed inside VimEnter autocmd. But now I want to open denite prompt when no files have been passed to vim as arguments.

au VimEnter * if argc() == 0 | exe ":Denite `finddir('.git', ';') != '' ? 'file_rec/git' : 'file_rec'`"

Which is quite easy, but the problem is that at this point vim still doesn't know anything about my custom 'file_rec/git' command.

I've tried to place initialization into ~/.vim/after/plugin/denite.vim, but that doesn't help. Vim is saying that he basically doesn't know what denite is at this point.

  • Try to run :scriptnames to see which scripts are loaded in which order. – laktak Apr 8 '17 at 18:29
  • @laktak Well, obviously ~/.vim/after/plugin/denite.vim is loaded before denite plugin, and scriptnames confirmed that. But now what? – user1685095 Apr 8 '17 at 22:22
  • well it's good to see that your scripts are loaded but are you sure that ~/.vim/after/plugin/denite.vim is loaded before the plugin? If yes then that's the problem. – laktak Apr 10 '17 at 13:06
  • @laktak Yes, I'm sure and obviously that's the problem. But is it supposed to be that way or not? – user1685095 Apr 10 '17 at 13:17
1

:help startup describes what Vim does on startup. I won't repeat the full details here, but you're correct that packages are loaded right after the initialization files (vimrc etc.) However, you can use the :packloadall to do this earlier if desired.

That being said, the VimEnter autocmd is run as the last step, and packages should have been loaded at this point, so that should work. Your autocommand does look funky though:

au VimEnter * if argc() == 0 | exe ":Denite `finddir('.git', ';') != '' ? 'file_rec/git' : 'file_rec'`"
  • Why is there no endif? That seems like an error.
  • What are those `s? Are you sure that's correct?
  • I've actually already done this another way, but ` stuff is from denite docs. – user1685095 Apr 22 '17 at 11:21
  • You're still missing an endif, though @user1685095 – Martin Tournoij Apr 22 '17 at 11:31
  • Yeah, it probably is, but I can't find out, because I've came up with different solution. As to packloadall, it's obviously so, but I wouldn't want to do things that vim is already doing automatically manually just because I don't like the order in which it does so. I also thought about making denite optional and load it explicitly in vimrc, but this is... wrong let's say. Customizing particular plugin after it is actually initialized is what should be possible. – user1685095 Apr 22 '17 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.