Skip to content

Commit

Permalink
fix: protect function lazy loading against asyncronous loops
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Feb 1, 2024
1 parent af8311f commit 3c7489a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/astrocore/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ function M.load_plugin_with_func(plugin, module, ...)
local old_func = module[func]
module[func] = function(...)
module[func] = old_func
require("lazy").load { plugins = { plugin } }
module[func](...)
local vars = { ... }
vim.schedule(function()
require("lazy").load { plugins = { plugin } }
module[func]((unpack or table.unpack)(vars))
end)
end
end
end
Expand Down

0 comments on commit 3c7489a

Please sign in to comment.