k-takata/minpac

`start` plugins loaded before `.vimrc`

mrcjkb opened this issue · 5 comments

mrcjkb commented

It appears that start plugins are loaded/sourced before the .vimrc, even though the readme says otherwise:

Plugins installed under pack/*/start/ are automatically added to the 'runtimepath' after .vimrc is sourced.

To reproduce:

  • Install a start plugin that has a ftplugin/vim.vim file, containing:
if g:foo_bar
    echom "foo_bar is set"
endif
  • Set g:foo_bar = true in .vimrc

  • Open a vim file: vim test.vim

Expected: Vim prints foo_bar is set
Actual: Nothing.

If I manually add a plugin to the default packpath (without minpac), I cannot reproduce the issue. So I don't think it's a Neovim bug.

I've also been able to reproduce this behaviour with the Neovim derivation in nixpkgs, and will investigate further on that end.
It wraps Neovim with --cmd "set packpath^=" and ---cmd "set rtp^=" - I believe it may be related to that.
Does minpac do something similar?

Does minpac do something similar?

if has('nvim') && isdirectory(l:dir . '/rplugin')
" Required for :UpdateRemotePlugins.
call s:add_rtp(l:dir)
endif

If a plugin has rplugin directory, minpac add it to rtp to support :UpdateRemotePlugins command.

mrcjkb commented

Does minpac do something similar?

if has('nvim') && isdirectory(l:dir . '/rplugin')
" Required for :UpdateRemotePlugins.
call s:add_rtp(l:dir)
endif

If a plugin has rplugin directory, minpac add it to rtp to support :UpdateRemotePlugins command.

🤔 that's not the case for the affected plugin.

Sorry for late.
Could you show the result of :scriptnames? Is the plugin loaded before your vimrc?
Could you also show your vimrc? minimal reproducible example should be better.

mrcjkb commented

No problem 😃

I don't actually use minpac.
This was reported to me by a user of one of the plugins I maintain, who uses minpac (@adaszko).

I was able to reproduce the same behaviour using the the Nix neovim package, which also uses packpath to manage plugins. But I wasn't able to reproduce it with plain (neo)vim without a plugin manager, and by cloning plugins into a start directory manually.

That's why I opened the issue here.
I am very tight on free time right now, and @adaszko was able to work around the issue by moving it to opt and using packadd!.

So it will probably be some time before I get around to setting up an example with minpac.

mrcjkb commented

I've played around with this and come to the conclusion that (at least for my nix setup), this is caused by a call to syntax on or syntax enable in init.vim

See this repo which reproduces it.

I could not reproduce it with vim. Only neovim. So I think this issue can be closed.