onedarkpro.nvim
onedarkpro.nvim copied to clipboard
Improve startup time by compiling user customizations and computed values
Lots of color schemes do something like this: https://github.com/EdenEast/nightfox.nvim/blob/main/lua/nightfox/lib/compile.lua
It can improve startup time by quite a bit. I love onedarkpro.nvim but according to :PackerProfile it’s one of the plugins that takes the longest to source on startup.
I can work on a PR for this probably tomorrow and early next week.
This is absolutely on the roadmap. The rewrite was done with these types of features in mind. I've half baked something which I'll merge in the next week. Need to decide how I'll get filetype highlights working with it too.
Oh awesome, glad to hear you’ve got something in the works. Let me know if there’s any way I can help
@mrjones2014 - Would love to get your feedback on startup times after 565f7b463640412825a066bc7d20db4f5c352b56!
Nice, funny enough I was just looking at this issue about an hour ago 🤣
I’ll take a look shortly
It seems to take pretty much the same time for me.
Around 6ms.
fluctuates between 5-9ms
Well that just sucks 😆. Using PackerCompile?
Using vim-startuptime I see 0.74ms with caching and 3.61ms without.
Also takes it down to 64th place in overall load times down from 13th
I might be doing something wrong, unsure. Do you see anything in my config that stands out?
https://github.com/mrjones2014/dotfiles/blob/master/.config/nvim/lua/my/configure/theme.lua
It all looks okay. You're loading all of the plugins which will add a tonne of weight and if you've got custom Telescope highlight groups you may want to set telescope = false in the plugins section.
I wonder if the so called "improvement" on my side is due to my measuring tool of choice.
There should definitely be an improvement though as we're not parsing all of the highlight groups for all of the editor, syntax and plugins; injecting colors and styles. That's probably about 500 highlight groups that we're avoiding.
I'll try enabling only the plugins I'm using and see if that helps.
Hmm, it still has about the same startup time for me.
So I happened to find and manually run the :OnedarkproCache command and it shaved about 70% off the startup time.
Any idea why caching = true in my config wouldn't be doing that automatically?
So I happened to find and manually run the
:OnedarkproCachecommand and it shaved about 70% off the startup time.Any idea why
caching = truein my config wouldn't be doing that automatically?
This was a bit confusing to me too--wasn't sure if the cache would be automatically created or not when caching is set to true (and hence if the provided commands would be required or just utilities) until I found the little note about auto commands in the README.
little note about auto commands in the README.
Ah, I didn't see this before.
I'd recommend actually changing it from a ColorScheme autocmd to a User PackerCompileDone autocmd, that way you only recompile the cache when you :PackerCompile, not every time you set the colorscheme.
This is great feedback. I've just pushed a change which detects if caching = true and if no cache file exists. It will then automatically generate a cache for the user. Please let me know if that works for you guys
That seems to work, but won't recompile on changes, right? For that you'd still need an autocmd.
I'd recommend updating the bit in the README.md to recommend autocmding on User PackerCompileDone if using packer, rather than ColorScheme since that will pretty much run every time you open Neovim I think.
Also, my onedarkpro.nvim startup time is sub-2ms now 🎉
This is great to hear! I'll update the readme later. If you guys have some autocommands to share for how you're regenerating the cache, would love to see them.
using legendary.nvim to bind my autocmds, I have an autocmd table like this:
{
-- recompile OneDarkPro.nvim cache on :PackerCompile
name = 'RecompileOnedarkproCache',
{
'User',
':OnedarkproCache',
opts = {
pattern = 'PackerCompileDone',
},
},
}
Or in vanilla Neovim APIs:
vim.api.nvim_create_autocmd('User', {
command = 'OnedarkproCache',
pattern = 'PackerCompileDone',
group = vim.api.nvim_create_augroup('OnedarkproCacheOnPackerCompile', { clear = true })
})