-
Notifications
You must be signed in to change notification settings - Fork 298
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
[Bug Report] ftdetect/*.vim files are sourced twice #706
Comments
They are sourced twice to support different loading scenarios on vim, nvim and different package managers for vim like vim pack, vim-plug, etc. second load takes 0ms because code is not executed |
You might want to read vim/vim#7056 Sourcing twice is actually for vim-polyglot to load faster, not slower, because it ensures it's loaded before vim-native ftdetect, preventing it from loading second time fully, and saving you 25ms of startup time. In fact it makes vim start faster than without any plugins. |
I'm not talking about The reason I reported this issue is that I found my custom augroup filetypedetect
runtime! filetype.vim
runtime! ftdetect/*.vim
augroup END From what I've digged, But I've never thought about when loading vim-polyglot with different pkg managers. I really have no idea about this part. If I wanna prevent my custom |
I need to debug this.. no idea why it happens |
Does this bug happen when you install plugin without vim-polyglot?
No
Describe the bug:
From
vim --startuptime
log, I found myftdetect/*.vim
files are loaded twice. After lots of time digging, I figured out it was related with theses lines inautoload/polyglot/init.vim
, first introduces in c45f0b8To put it in a simple way,
runtime! filetype.vim
sourcesshare/vim/vim82/filetype.vim
, which also runruntime! ftdetect/*.vim
For detailed analysis
Analysis base from verbose log
vim -V99debug.log
.Let's begin with how a
filetype.vim
is loaded. Unlikeplugin/
files handled by vim automatically,filetype.vim
files are only loaded with executingfiletype plugin indent on
.filetype plugin indent on
triggers searching forfiletype.vim
Found this plugin
vim-polyglot
first, sourcesvim-ployglot/filetype.vim
, which justcall polyglot#init#init()
init.vim
func! polyglot#init#init
empty to avoid call loopruntime! filetype.vim
filetype.vim
vim-ployglot/filetype.vim
, skippedshare/vim/vim82/filetype.vim
runtime! ftdetect/*.vim
ftdetect/*.vim
and sourcing them (first time loading)runtime! ftdetect/*.vim
ftdetect/*.vim
and sourcing them (second time loading)It found the default
share/vim/vim82/filetype.vim
, cause variabledid_load_filetypes
is set,finish
earlyThe text was updated successfully, but these errors were encountered: