k-takata / minpac

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

Fix issues with sourcing plugins #118

Closed sheerun closed 3 years ago

sheerun commented 3 years ago

I'm author of vim-polyglot plugin which as very specific requirements when it comes about source files of plugins. Specifically it is required that its filetype script is loaded before vim's filetype script. Also the order of loading packages is important, vim-polyglot should defined first in ~/.vimrc, and should also be loaded first, before any other plugins. Consider ~/.vimrc that defines 2 plugins to load. Every other package manager sources files in this order:

  1. ftdetect dirs of plugins
  2. ftdetect dir of vim runtime
  3. plugin dirs of vim plugins
  4. plugin dir of vim runtime

You can see it in action for vim-plug (vundle, pathogen, dein.vim work the same). The same story is even with vim8 packages when using start plugins + packload (here plugin load order depends on names of plugins), and also vim8 opt packages + packadd command (though here filetype.vim is loaded in reversed order...).

Here finally we can compare with what minpac does. First of all load order is different on vim and nvim, and it is wrong in both cases.

Vim load order:

  1. ftdetect files of plugins (in reverse alphabetical order, instead of order of definition)
  2. plugin dir of vim runtime
  3. filetype.vim dir of vim runtime
  4. plugin dirs of vim plugins, in reverse order

Nvim load order (even worse):

  1. filetype.vim of vim runtime
  2. plugin dir of vim runtime
  3. ftdetect files of plugins (but this time in alphabetical order, instead of order of definition)
  4. runtime ftdetect files again 5 plugin dir of vim plugins

As you can see nothing is consistent and this PR changes it by loading plugins in correct order, on all platforms, in correct time, as other plugin managers do, and exactly the same on vim and nvim. I'm doing to by installing all packages as opt, and manually adding them to runtimepath, instead of either calling packadd, packadd!, packload, all of which have weird behaviors.

k-takata commented 3 years ago

Handling 'runtimepath' is not a task of minpac (except for supporting neovim's :UpdateRemotePlugins command). It's a task of Vim's packages feature. It seems that the original issue in sheerun/vim-polyglot#571 has been solved. So, closing.