k-takata / minpac

A minimal package manager for Vim 8+ (and Neovim)
835 stars 30 forks source link

`start` plugins loaded before `.vimrc` #152

Closed mrcjkb closed 8 months ago

mrcjkb commented 9 months ago

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:

if g:foo_bar
    echom "foo_bar is set"
endif

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?

k-takata commented 9 months ago

Does minpac do something similar?

https://github.com/k-takata/minpac/blob/79f60e0f89b8b68397c8c0f8ad356274f7fe76ae/autoload/minpac/impl.vim#L358-L361 If a plugin has rplugin directory, minpac add it to rtp to support :UpdateRemotePlugins command.

mrcjkb commented 9 months ago

Does minpac do something similar?

https://github.com/k-takata/minpac/blob/79f60e0f89b8b68397c8c0f8ad356274f7fe76ae/autoload/minpac/impl.vim#L358-L361

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

:thinking: that's not the case for the affected plugin.

k-takata commented 8 months ago

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 8 months ago

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 8 months ago

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.