rakr / vim-one

Adaptation of one-light and one-dark colorschemes for Vim
MIT License
2k stars 197 forks source link

Startup time #74

Open sudoremo opened 6 years ago

sudoremo commented 6 years ago

This plugin significantly adds to my vim / nvim startup time by contributing 328ms to it. Is this a known issue / is there any way to improve this startup time?

Thanks for any help and also thanks for this wonderful plugin - it was the first vim plugin I used back when I switched from Atom! 👍

rakr commented 6 years ago

This issue has not yet been reported, will need some investigation.

rnevius commented 5 years ago

Just bumping this issue with the results of my profiler:

vim-one load time
Vim 233.36 ms
Neovim 82.64 ms
geoffharcourt commented 5 years ago

I think this performance hit on startup (even when the scheme isn't active) is due to the use of functions to define the colors vs. hard-coded values. It would be a non-trivial effort to rewrite those (I think this was built from the base16 generator originally), but that might be a contributor.

h/t @devinrm for the suggestion.

geoffharcourt commented 5 years ago

I should clarify that I don't think this is easy, and it might reduce the comprehensiveness of the scheme, limiting the size of the group that can use it.

laggardkernel commented 5 years ago

@geoffharcourt Thx for your explanation. I just made a hard-coded fork of vim-one and the startup time improves dramatically.

# the original one
❯ vim-profiler.py -r 10 nvim
=====================================
Top 10 plugins slowing nvim's startup
=====================================
1       170.621   vim-one
2         6.274   vim-airline
3         4.038   vim-polyglot
4         3.496   coc.nvim
5         2.645   colorizer
6         2.413   vim-textobj-xmlattr
7         2.313   vim-textobj-comment
8         1.795   vim-sensible
9         1.664   vim-textobj-line
10        1.341   ctrlp.vim
=====================================

# the hard-coded
❯ vim-profiler.py -r 10 nvim
=====================================
Top 10 plugins slowing nvim's startup
=====================================
1        11.172   vim-one
2         6.650   vim-airline
3         3.960   vim-polyglot
4         3.579   coc.nvim
5         2.830   colorizer
6         2.405   vim-textobj-comment
7         2.372   vim-textobj-xmlattr
8         1.732   vim-sensible
9         1.724   vim-textobj-line
10        1.430   ctrlp.vim
=====================================

Italic setting let g:one_allow_italics = 1 is available.

geoffharcourt commented 5 years ago

@laggardkernel did you have a script or programmatic way to do this?

laggardkernel commented 5 years ago

@geoffharcourt No, not yet.

I used command nvim -u only-for-one.vim -V20output.log to get the verbose sourcing info during nvim startup. The configuration file only-for-one.vim only included the vim-one plugin and some colorscheme settings. After that, I did some searching in the output file and extract all the related highlight statements from it.

As far as I know, it's the most simple way to convert the original project to a hard-coded color scheme. Maybe I'll restructure the code later. Haven't made up my mind.

rakr commented 5 years ago

Thanks for your patience, thanks to @laggardkernel and the use of better approximation, this issue should now be fixed by the latest commit to master. @laggardkernel As commented on the PR, I had to manually merge the PR, Thank you very much for your contribution

laggardkernel commented 5 years ago

@rakr Thank God you're back. There's another optimization I borrowed from vim theme gruvbox that reuses highlight definitions by hi link. Maybe we could add it as well. I'll rebase it onto the master branch and open a pr once I have a spare moment.