perf(commands): defer module loading#3210
Conversation
|
I use my custom, simple Lua module lazy loader. In that way nvim-tree isn't setup and no module is loaded before calling function defined in keymap. It has a drawback: Rarely, but still, I would like to start using nvim-tree with such command. I know that direct call to That |
alex-courtis
left a comment
There was a problem hiding this comment.
Normally I'd give dire warnings about lazy loading, predictable ordering and not using API, however you know exactly what you're doing :)
This looks good/safe and won't change anything.
That
setup()logic could exist inplugin/nvim-tree.luainstead.
I'm not quite sure what you mean... would that allow you to avoid requiring commands? Would that not load all the modules?
Either way, sounds good. Do you want to just push it?
| }, | ||
| command = function(c) | ||
| api.tree.open({ path = c.args }) | ||
| require("nvim-tree.api").tree.open({ path = c.args }) |
There was a problem hiding this comment.
Initial thought was to use a common function like
local function api()
require("nvim-tree.api")
endhowever that would just obscure things.
The inline require make it really clear what's going on.
Ah, you probably meant pushing plugin approach here 😀 This change seems to be safe to merge separately. Using |
alex-courtis
left a comment
There was a problem hiding this comment.
All working, many thanks for your contribution!
No description provided.