Skip to content

Conversation

@saygo-png
Copy link
Contributor

@saygo-png saygo-png commented Nov 10, 2025

Closes: #3313

This implementation uses a loop to set the globals. Since this is per plugin many of these loops might be created. I don't know if this will affect performance and I don't know how to benchmark this.

I tested this with vimVisualMulti and rainbow, both plugins can be successfully lazyloaded.

With this change all 400+ plugin modules we have will support lazyloading!

Copy link
Member

@GaetanLepage GaetanLepage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does delaying setting global variables actually corresponds to "lazy loading"?
No (plugin) code is really executed when one runs vim.g["foo_bar"] = true, correct?

@GaetanLepage

This comment was marked as off-topic.

@saygo-png
Copy link
Contributor Author

No (plugin) code is really executed when one runs vim.g["foo_bar"] = true, correct?

Yes

Does delaying setting global variables actually corresponds to "lazy loading"?

As i understand lazyloading is not just loading the plugin lazily, it's also about loading it's config lazily. We do this for Lua plugins, and it's done in lz-n docs for vimscript ones. Look at vim-startuptime here https://github.com/lumen-oss/lz.n?tab=readme-ov-file#examples (Though as i'm writing this i realise they reccomend using before instead of after for vimscript plugins)

Signed-off-by: saygo-png <saygo.mail@proton.me>
@saygo-png
Copy link
Contributor Author

Sorry, missed a big issue. Previous code always generated Lua even if settings was empty or set to things that filter out. The code I pushed makes it work properly but it looks horrible. Is there some better way to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] mkVimPlugin support lazy loading

2 participants