gelguy / wilder.nvim

A more adventurous wildmenu
MIT License
1.36k stars 34 forks source link

Startup cost is too high #89

Open kkharji opened 3 years ago

kkharji commented 3 years ago

Hey @gelguy amazing work.

I wanted to try out wilder but the cost is ridiculously high.

using startuptime.vim

event                  time percent plot
wilder.vim           207.48   73.20 ██████████████████████████
python3.vim          201.00   70.91 █████████████████████████▏
init.lua              36.36   12.83 ████▌
filetype.vim           6.14    2.17 ▊
loading plugins        6.07    2.14 ▊
loading packages       5.34    1.88 ▋
syntax.vim             2.96    1.04 ▍
synload.vim            2.83    1.00 ▍
tokyonight.vim         2.34    0.82 ▎
first screen update    2.32    0.82 ▎
done waiting for UI    2.29    0.81 ▎
reading ShaDa          2.17    0.77 ▎
tokyonight.vim         1.65    0.58 ▎
VimEnter autocommand   1.51    0.53 ▎
expanding arguments    1.47    0.52 ▏
bindings.lua           1.32    0.47 ▏
opening buffers        1.27    0.45 ▏
locale set             0.74    0.26 ▏
cmdline.vim            0.50    0.18 ▏
loading after plugin   0.49    0.17
init highlight         0.48    0.17
inits 1                0.47    0.16
nvim-treesitter.vim    0.43    0.15
nvim-treesitter-text   0.42    0.15
main.vim               0.39    0.14

I have more than 70 plugins installed and none of them take more than 2%

Any plans to port wilder.nvim to lua?

Thanks

gelguy commented 3 years ago

Hi, thanks for trying out the plugin!

There's a section in the README which describes how to reduce the startup time: https://github.com/gelguy/wilder.nvim#faster-startup-time.

The plugin will be lazily loaded on the first CmdlineEnter. Note that the plugin will still take 200ms to load, just that it isn't loaded on startup.

Regarding porting to lua, it's possible but at the moment I want to keep Vim compatibility.

I'll be interested to know if the CmdlineEnter lazy load suggestion works for you, or even that is too slow (since the first : command will have to load the plugin). If it's still too slow I can explore other options.

akinsho commented 3 years ago

Drive by comment: I use wilder whilst lazy loading on CmdlineEnter with packer.nvim and that is a big improvement, the load time isn't really discernible at that point. It is still a shame that that is needed at all but not a deal breaker since it can be deferred.

For anyone reading this that is a packer user, this works for the most part but packer has a few quirks when it comes to multiple remote plugins so if you use other python based plugins I suggest lazy loading on CursorHold or something.

tony commented 2 years ago

Can the workaround also gracefully fallback when wilder.nvim isn't in the plugins? For me it always will error on CmdlineEnter.

No permutation of exists() and checking for if &rtp =~ 'wilder.nvim' works in all cases. It either doesn't startup wilder, breaks lazy loading on the first CmdlineEnter.

System: Using vim 9.0, patches 1-477, wilder.nvim at 679f348.

Assume the latest Faster startup time example:

" ++once supported in Nvim 0.4+ and Vim 8.1+
autocmd CmdlineEnter * ++once call s:wilder_init() | call wilder#main#start()

function! s:wilder_init() abort
  call wilder#setup(...)
  call wilder#set_option(..., ...)

  call wilder#set_option('pipeline', ...)
  call wilder#set_option('renderer', ...)
endfunction
My specific one ```viml if &rtp =~ 'wilder.nvim' " ++once supported in Nvim 0.4+ and Vim 8.1+ autocmd CmdlineEnter * ++once call s:wilder_init() | call g:wilder#main#start() function! s:wilder_init() abort call wilder#setup({'modes': [':', '/', '?']}) call wilder#set_option('use_python_remote_plugin', 0) endfunction endif ```
Error detected while processing CmdlineEnter Autocommands for "*"..function <SNR>5_wilder_init:
E117: Unknown function: wilder#setup 

Is there any way to get this to fallback safely when the plugin hasn't been installed yet?