Nvim-tree lazy loading error - Not an editor command: NvimTreeToggle #2298
Replies: 2 comments 3 replies
|
Startup is difficult, due to the somewhat nondeterministic ordering of startup behaviour. The lazy plugin and session loading makes things greatly more difficult. Perhaps this might be of assistance: wiki: Workaround when using rmagatti/auto-session It may be pragmatic to avoid lazy loading for nvim-tree. There is no performance or resource benefit to lazy loading; nvim-tree does nothing but parse/set you configuration on |
|
nvim-tree takes 500 ms+, which makes the startup of neovim a little bit slow, so I prefer to lazily load it. I think this works: return {
"nvim-tree/nvim-tree.lua",
lazy = true,
opts = {},
keys = {
{
"<Leader>e",
function ()
require("nvim-tree.api").tree.toggle({ find_file = true })
end,
desc = "Explorer NvimTree (Dir of Current File)",
},
{
"<Leader>E",
function ()
require("nvim-tree.api").tree.toggle({ path = vim.uv.cwd() })
end,
desc = "Explorer NvimTree (cwd)",
},
},
}And running |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hey there,
I have a problem when trying to lazy load nvim-tree while also loading a session at startup.
Below is my nvim-tree config:
When I press
<leader>eafter loading an existing session, I get the following message:In the following scenario:
<leader>eto toggle nvim-tree. It should then lazy load and appear.<leader>eagain, this time the error above occurs.After investigating a bit, I found the culprit to be some global nvim-tree variables being saved into the session file.
I have
set sessionoptions+=globalsas some plugins require it to function. However, this also leads to the following global variables being saved to the session file:For some reason, these are causing conflicts in the lazy loading of nvim-tree. If I manually set
NvimTreeSetup = 0, then upon reloading the session,<leader>eworks fine, until the next time the session is loading, at which point NvimTreeSetup is set back to 1 and I get the same errors again.What can be done about this? Should I just manually set the global variable to 0 upon loading the session via a session load hook? Kinda hacky but could work I guess.
All reactions