local data = vim.fn.stdpath('data') local paths = { async_nvim = data .. '/lazy/async.nvim/lua/async.lua', promise = data .. '/lazy/promise-async/lua/async.lua', } localloaded = {} localfunctionload(kind) ifnotloaded[kind] thenloaded[kind] = dofile(paths[kind]) end returnloaded[kind] end
local orig_require = _G.require _G.require = function(modname, ...) if modname ~= 'async'thenreturn orig_require(modname, ...) end
for lvl = 2, 16do local info = debug.getinfo(lvl, 'S') ifnot info thenbreakend local src = info.source or'' if src:find('refactoring', 1, true) thenreturnload('async_nvim') end if src:find('nvim-ufo', 1, true) thenreturnload('promise') end
if src:find('fundo', 1, true) thenreturnload('promise') end if src:find('promise-async', 1, true) thenreturnload('promise') end end returnload('async_nvim') end