From ffabe91b2d72d686fb21d3159e20bf8faab7ed24 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 20 Dec 2022 16:41:11 +0100 Subject: [PATCH] fix(cache): if mod is loaded already in the loader, then return that --- lua/lazy/core/cache.lua | 6 ++++++ lua/lazy/core/plugin.lua | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua index b408a33..a57dabb 100644 --- a/lua/lazy/core/cache.lua +++ b/lua/lazy/core/cache.lua @@ -88,6 +88,12 @@ function M.loader(modname) local chunk, err if entry and M.check_path(modname, entry.modpath) then + local mod = package.loaded[modname] + if type(mod) == "table" then + return function() + return mod + end + end chunk, err = M.load(modname, entry.modpath) else -- find the modpath and load the module diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index a1bebb8..65172da 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -36,10 +36,10 @@ local M = {} ---@field pin? boolean ---@class LazyPlugin: LazyPluginHandlers,LazyPluginHooks,LazyPluginRef ----@field [1] string ----@field name string display name and name used for plugin config files ----@field url string ----@field dir string +---@field [1] string? +---@field name string? display name and name used for plugin config files +---@field url string? +---@field dir string? ---@field enabled? boolean|(fun():boolean) ---@field lazy? boolean ---@field dev? boolean If set, then link to the respective folder under your ~/projects