@@ -146,13 +146,20 @@ function Spec:warn(msg)
146
146
self :log (msg , vim .log .levels .WARN )
147
147
end
148
148
149
- function Spec :fix_disabled ()
149
+ function Spec :fix_cond ()
150
150
for _ , plugin in pairs (self .plugins ) do
151
- if not plugin .name or not plugin .dir then
152
- self :error (" Plugin spec for **" .. plugin .name .. " ** not found.\n ```lua\n " .. vim .inspect (plugin ) .. " \n ```" )
153
- self .plugins [plugin .name ] = nil
151
+ local cond = plugin .cond
152
+ if cond == nil then
153
+ cond = Config .options .defaults .cond
154
+ end
155
+ if cond == false or (type (cond ) == " function" and not cond (plugin )) then
156
+ plugin ._ .cond = false
157
+ plugin .enabled = false
154
158
end
155
159
end
160
+ end
161
+
162
+ function Spec :fix_optional ()
156
163
if not self .optional then
157
164
--- @param plugin LazyPlugin
158
165
local function all_optional (plugin )
@@ -166,6 +173,18 @@ function Spec:fix_disabled()
166
173
end
167
174
end
168
175
end
176
+ end
177
+
178
+ function Spec :fix_disabled ()
179
+ for _ , plugin in pairs (self .plugins ) do
180
+ if not plugin .name or not plugin .dir then
181
+ self :error (" Plugin spec for **" .. plugin .name .. " ** not found.\n ```lua\n " .. vim .inspect (plugin ) .. " \n ```" )
182
+ self .plugins [plugin .name ] = nil
183
+ end
184
+ end
185
+
186
+ self :fix_optional ()
187
+ self :fix_cond ()
169
188
170
189
--- @type table<string,string[]> plugin to parent plugin
171
190
local dep_of = {}
@@ -384,6 +403,12 @@ function M.update_state()
384
403
end
385
404
end
386
405
406
+ for _ , plugin in pairs (Config .spec .disabled ) do
407
+ if plugin ._ .cond == false then
408
+ installed [plugin .name ] = nil
409
+ end
410
+ end
411
+
387
412
Config .to_clean = {}
388
413
for pack , dir_type in pairs (installed ) do
389
414
table.insert (Config .to_clean , {
0 commit comments