New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent loading order of packages and their parts #7056
Comments
Also ftdetect can be not loaded if packadd! is used and plugin is in opt (but it works if it's in start).... |
Oh, plus vim and nvim have different behavior for each of these: k-takata/minpac#118 (comment) (minpac depends on vim8 / neovim packages to load plugins instead of modiifying rtp like vim-plug or vundle) I mean in current form vim8 packages are pretty much unstable, and actually much harder to work with than any other solution available. I think they need v2.0 with much simpler logic, something like this:
|
"the vim-polyglot plugin I'm developing needs to be loaded before vim's filetype.vim". That is a very difficult restriction you are making. The user may have "syntax on" somewhere you don't expect it. Why not remove this dependency? |
Well, for me it's difference between 60ms and 10ms of loading time, because that's how much hundreds of |
For filetypes it's basically "last one wins", so why do you need to remove what was added before? |
runtimepath works well for all files except initial ftdetect files, or rather filetype.vim (e.g. ruby.vim of vim-polyglot is properly loaded always before vim's). Indeed there's "last wins", but changing filetype multiple times for loaded file has its own performance penalty, so it's best handled by ensuring correct filetype is applied in the first place (vim uses |
I mean I can hack anything as long as something is loaded before vim's runtime files. Current implementation doesn't load anything at all, so there's no way around it. I basically must live with vim runtime files being sourced first, and I cannot do anything about it, this is the gist of this issue. |
runtimepath works well for all files except initial ftdetect files, or
rather filetype.vim (e.g. ruby.vim of vim-polyglot is properly loaded
always before vim's). Indeed there's "last wins", but changing
filetype multiple for loaded file has its own performance penalty, so
it's best handled by ensuring correct filetype is applied in the first
place (vim uses `setf` wchich is "first one wins").
Yeah, that's right, using "setf" is different. And you don't really
want to set one filetype and then overrule it, causing multiple filetype
plugins to be loaded in sequence.
I would think it works to overrule the autocommand from filetype.vim:
au BufRead *.js
--- Autocommands ---
filetypedetect BufRead
*.js setf javascript
au! filetypedetect BufNewFile,BufRead *.js setf myJs
au BufRead *.js
--- Autocommands ---
filetypedetect BufRead
*.js setf myJs
…--
How To Keep A Healthy Level Of Insanity:
6. In the memo field of all your checks, write "for sexual favors".
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Yes indeed, I've mentioned I can use |
I've decided to not use As of now the issue is twofold:
This could all be solved by instructing vim to source second plugin first. which currently isn't encouraged ("packages should not depend on the loading order") or even possible to enforce with vim8 packages |
Adam Stankiewicz wrote:
I've decided to not use `au!` for each overridden filetype, but `au!
filetypedetect` + basically copy all vim's filetype.vim into
vim-polyglot, which finally I know will load last :P
As of now the issue is twofold:
1. vim's filetype.vim is unnecessairly loaded which takes 25ms (it is
fully overridden by vim-polyglot)
I don't see how you can override all of filetype.vim. Do you mean to
clear it and load it again?
2. `au!` can't be used by other plugins because it depends on load
order of plugins, and also it requires that arguments are exactly the
same which they often aren't. for example one plugin can use `au!
BufRead Makefile.am setf make`, when second uses `au! BufRead
[Mm]akeifile.am setf makefile`.
This could all by instructing vim to source second plugin first. which
currently isn't encouraged ("packages should not depend on the loading
order") or even possible to enforce with vim8 packages
It's very tricky to make plugins load in the right order. Especially if
you don't know what the right order is.
Autocommands are executed in the order they are defined. If a later
plugin adds an autocommand for filetype detection, it can overrule what
happened earlier:
au BufNewFile,BufRead *.mine set filetype=mine
In filetype.vim ":setfiletype" is used, which won't change 'filetype' if
it was already set, thus it doesn't matter if it's loaded before or
after this. The only disadvantage is that 'filetype' might be set
twice. Is that really a problem?
If two plugins fight over the same rule, well, then there is a problem.
…--
How To Keep A Healthy Level Of Insanity:
16. Have your coworkers address you by your wrestling name, Rock Hard Kim.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Yes indeed, I've mentioned I can use `au!` but it has heavy
performance penalty. 60ms vs 10ms loading time
I suppose that's because it has to go over all the autocommand to find
the ones that need to be deleted. Perhaps we can make this faster, that
is useful in many ways.
So this delay happens if, after "filetype on", you use an "au!" command?
Can you give an example?
…--
How To Keep A Healthy Level Of Insanity:
15. Five days in advance, tell your friends you can't attend their
party because you're not in the mood.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
In case vim's filetype.vim is sourced first, I'm running In case vim's filetype.vim is sourced last, thanks to
It isn't one-time delay, it's difference of calling hundreds of Currently without vim-polyglot loading time is as follows:
With vim-polyglot loaded after filetype.vim loading time is as follows:
If vim-polyglot is loaded before filetype.vim, then loading time is as follows:
So using vim-polyglot makes startup time faster than native, if sourced in correct order, and slower than native if in incorrect order. |
Describe the bug
It seems there is different loading order of plugins and their parts if using empty vimrc / packload / packadd / packadd!
To Reproduce
I've created https://github.com/sheerun/vim-packages-bug that should better illustrate the problem. You can run there
bash script.sh
to produce following output:~/.vim/pack/*/start/*
without pack commands in ~/.vimrc~/.vim/pack/*/start/*
withpackload
~/.vim/pack/*/start/*
withpackadd vim-packages-bug
in vimrc~/.vim/pack/*/start/*
withpackadd! vim-packages-bug
in vimrc~/.vim/pack/*/opt/*
withpackadd vim-packages-bug
in vimrc~/.vim/pack/*/opt/*
withpackadd! vim-packages-bug
in vimrcTo summarize
plugins
can be loaded before or after vim plugins, possibly multiple timesftdetect
is loaded always after vim filetypes, possibly multiple times (all other package managers always load ftdetect before vim native files..)Things get even worse if multiple packages are used, because then they can be loaded in alphabetical order (no pack commands), in defined order (
packadd
commands), or reverse defined order (packadd!
commands), and all combinations of these. Order of loading is also affected if some plugins are callingfiletype plugin indent on
within themselves (like vim-sensible). Also all other package managers are loading filetype.vim of plugin while vim8 packages do not, ever.Honestly it's pretty overwhelming for someone who would like to depend on some order of loading in package manager (the vim-polyglot plugin I'm developing needs to be loaded before vim's filetype.vim, and other plugins overriding its autocommands).
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: