onedark.nvim
onedark.nvim copied to clipboard
refactor: use nvim_set_hl to speed up startup time
On my machine, prior to this change, the colorscheme adds about 8ms to
the startup time of neovim. Using the newly introduced API
nvim_set_hl
, it’s a little under 3ms, so that’s more than a two times
speedup!
Special care is taken to handle the fmt
argument, as that’s the least
friendly to nvim_set_hl
.
This change strives to be backward compatible. Once neovim version 0.7.0 will be spread widely enough, further performance gain are within reach by:
- removing the fallback that calls
string.format
- defining the
group_settings
so that those can be passed tonvim_set_hl
directly
Using https://github.com/rhysd/vim-startuptime with vim-startuptime -vimpath nvim
, before the change on my machine I get:
AVERAGE MAX MIN
------------------------------
64.994300 65.748000 64.236000: ~/.config/nvim/init.lua
8.342700 8.888000 7.954000: ~/.local/share/nvim/site/pack/paqs/start/onedark.nvim/colors/onedark.lua
and after:
AVERAGE MAX MIN
------------------------------
60.578100 62.654000 59.836000: ~/.config/nvim/init.lua
6.268300 6.810000 5.928000: loading packages
3.631400 3.860000 3.472000: loading rtp plugins
2.773000 2.908000 2.604000: reading ShaDa
2.659900 2.859000 2.508000: ~/.local/share/nvim/site/pack/paqs/start/onedark.nvim/colors/onedark.lua
The latest commit will need to be squashed if this PR is merged, but in the meantime, it makes testers live easier because they can just pull from the branch.
fmt
was incorrectly handled previously, specifically the iteration was incorrect in Lua. The latest commit fixes that.
After daily driving this change, I have not noticed any more discrepancies compared to master
.
This plugin initially started with nvim_set_hl
. But we switched to vim highlight
to solve some color highlight issue. Let me check that once
Looking at the 0.7 changelog, it seems that nvim_set_hl
has been significantly improved, so hopefully that’ll work now.
Sure. Let me verify it this week and will merge if no issues
Cool, let me know if you need help!
Did you encounter any issues in the end?
ping @navarasu , in case the notification just got lost.
Rebased on the most recent master branch.
let's get this merged...