From 8564f6d22b78a4a0fba9811faa556159b6c90a49 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 22 May 2023 14:24:18 +0200 Subject: [PATCH] feat(plugin): added support for `weak` specs. They will not be included in the final spec if not specified somwhere else --- lua/lazy/core/plugin.lua | 7 +++++++ lua/lazy/types.lua | 1 + 2 files changed, 8 insertions(+) diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index f06a1ff..15d5b2d 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -141,6 +141,13 @@ function Spec:warn(msg) end function Spec:fix_disabled() + -- handle weak plugins + for _, plugin in pairs(self.plugins) do + if plugin.weak and not plugin._.super then + self.plugins[plugin.name] = nil + end + end + ---@type table plugin to parent plugin local dep_of = {} diff --git a/lua/lazy/types.lua b/lua/lazy/types.lua index 067450a..5b3821c 100644 --- a/lua/lazy/types.lua +++ b/lua/lazy/types.lua @@ -47,6 +47,7 @@ ---@field dir string ---@field enabled? boolean|(fun():boolean) ---@field cond? boolean|(fun():boolean) +---@field weak? boolean If set, then this plugin will not be added unless it is added somewhere else ---@field lazy? boolean ---@field priority? number Only useful for lazy=false plugins to force loading certain plugins first. Default priority is 50 ---@field dev? boolean If set, then link to the respective folder under your ~/projects