-
I was wondering if there is a way to set up a plugin B to lazy load after some plugin A gets loaded. Note, not before as in a dependency (in my use case, plugin B is actually dependent on plugin A). I'm guessing I could do this with a If you want to know specifics, I want to use nvim-lsp-file-operations and seeing as its functionality is pretty much entirely tied to NeoTree, it makes sense to me to tie the lazy loading to the loading of NeoTree. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @Trildar, Here are some examples I can think of: local variation = 1
-- using neotree's filetype
if variation == 1 then
return {
{
"antosha417/nvim-lsp-file-operations",
ft = "neo-tree",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-neo-tree/neo-tree.nvim",
},
config = true,
},
}
end
-- using LazyLoad
if variation == 2 then
return {
{
"antosha417/nvim-lsp-file-operations",
lazy = true,
init = function()
vim.api.nvim_create_autocmd("User", {
pattern = "LazyLoad",
callback = function(event)
if event.data == "neo-tree.nvim" then
require("lsp-file-operations")
return true
end
end,
})
end,
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-neo-tree/neo-tree.nvim",
},
config = true,
},
}
end
-- neotree specific solution:
if variation == 3 then
return {
{
"antosha417/nvim-lsp-file-operations",
lazy = true,
dependencies = {
"nvim-lua/plenary.nvim",
{
"nvim-neo-tree/neo-tree.nvim",
opts = {
event_handlers = {
{
event = "neo_tree_buffer_enter",
handler = function()
require("lsp-file-operations")
end,
},
},
},
-- more neo-tree config here
},
},
config = true,
},
}
end
-- as a dep of neotree, but postpone the setup of the plugin
-- this only works when the plugin needs the setup before being operational
if variation == 4 then
return {
{
"nvim-neo-tree/neo-tree.nvim",
cmd = "Neotree",
dependencies = {
"nvim-lua/plenary.nvim",
{
"antosha417/nvim-lsp-file-operations",
config = function()
vim.api.nvim_create_autocmd("User", {
pattern = "LazyLoad",
callback = function(event)
if event.data == "neo-tree.nvim" then
require("lsp-file-operations").setup()
return true
end
end,
})
end,
},
},
-- more neotree config here
},
}
end
return {} Best regards! |
Beta Was this translation helpful? Give feedback.
Hi @Trildar,
Here are some examples I can think of: