Skip to content

Commit eed1ef3

Browse files
committed
feat(commands): :Lazy! load now skips cond checks when loading plugins. Fixes #330
1 parent 2ef44e2 commit eed1ef3

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ return {
303303
version = nil,
304304
-- version = "*", -- enable this to try installing the latest stable versions of plugins
305305
},
306+
-- leave nil when passing the spec as the first argument to setup()
307+
spec = nil, ---@type LazySpec
306308
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
307309
concurrency = nil, ---@type number limit the maximum amount of concurrent tasks
308310
git = {
@@ -330,20 +332,21 @@ return {
330332
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
331333
border = "none",
332334
icons = {
333-
loaded = "",
334-
not_loaded = "",
335335
cmd = "",
336336
config = "",
337337
event = "",
338338
ft = "",
339339
init = "",
340+
import = "",
340341
keys = "",
342+
lazy = "",
343+
loaded = "",
344+
not_loaded = "",
341345
plugin = "",
342346
runtime = "",
343347
source = "",
344348
start = "",
345349
task = "",
346-
lazy = "",
347350
list = {
348351
"",
349352
"",
@@ -361,21 +364,15 @@ return {
361364

362365
-- open lazygit log
363366
["<localleader>l"] = function(plugin)
364-
require("lazy.util").open_cmd({ "lazygit", "log" }, {
367+
require("lazy.util").float_term({ "lazygit", "log" }, {
365368
cwd = plugin.dir,
366-
terminal = true,
367-
close_on_exit = true,
368-
enter = true,
369369
})
370370
end,
371371

372372
-- open a terminal for the plugin dir
373373
["<localleader>t"] = function(plugin)
374-
require("lazy.util").open_cmd({ vim.go.shell }, {
374+
require("lazy.util").float_term(nil, {
375375
cwd = plugin.dir,
376-
terminal = true,
377-
close_on_exit = true,
378-
enter = true,
379376
})
380377
end,
381378
},
@@ -410,7 +407,7 @@ return {
410407
-- The default is to disable on:
411408
-- * VimEnter: not useful to cache anything else beyond startup
412409
-- * BufReadPre: this will be triggered early when opening a file from the command line directly
413-
disable_events = { "VimEnter", "BufReadPre" },
410+
disable_events = { "UIEnter", "BufReadPre" },
414411
ttl = 3600 * 24 * 5, -- keep unused modules for up to 5 days
415412
},
416413
reset_packpath = true, -- reset the package path to improve startup time
@@ -498,7 +495,7 @@ Any operation can be started from the UI, with a sub command or an API function:
498495
| `:Lazy help` | `require("lazy").help()` | Toggle this help page |
499496
| `:Lazy home` | `require("lazy").home()` | Go back to plugin list |
500497
| `:Lazy install [plugins]` | `require("lazy").install(opts?)` | Install missing plugins |
501-
| `:Lazy load {plugins}` | `require("lazy").load(opts)` | Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim` |
498+
| `:Lazy load {plugins}` | `require("lazy").load(opts)` | Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim`. Use `:Lazy! load` to skip `cond` checks. |
502499
| `:Lazy log [plugins]` | `require("lazy").log(opts?)` | Show recent updates |
503500
| `:Lazy profile` | `require("lazy").profile()` | Show detailed profiling |
504501
| `:Lazy restore [plugins]` | `require("lazy").restore(opts?)` | Updates all plugins to the state in the lockfile. For a single plugin: restore it to the state in the lockfile or to a given commit under the cursor |
@@ -532,9 +529,11 @@ Stats API (`require("lazy").stats()`):
532529
-- when true, startuptime is the accurate cputime for the Neovim process. (Linux & Macos)
533530
-- this is more accurate than `nvim --startuptime`, and as such will be slightly higher
534531
-- when false, startuptime is calculated based on a delta with a timestamp when lazy started.
535-
startuptime_cputime = false,
532+
real_cputime = false,
536533
count = 0, -- total number of plugins
537534
loaded = 0, -- number of loaded plugins
535+
---@type table<string, number>
536+
times = {},
538537
}
539538
```
540539

@@ -738,6 +737,7 @@ To uninstall **lazy.nvim**, you need to remove the following files and directori
738737
| **LazyReasonCmd** | **_Operator_** | |
739738
| **LazyReasonEvent** | **_Constant_** | |
740739
| **LazyReasonFt** | **_Character_** | |
740+
| **LazyReasonImport** | **_Identifier_** | |
741741
| **LazyReasonKeys** | **_Statement_** | |
742742
| **LazyReasonPlugin** | **_Special_** | |
743743
| **LazyReasonRuntime** | **_@macro_** | |

lua/lazy/core/loader.lua

+6-4
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ end
157157
---@class Loader
158158
---@param plugins string|LazyPlugin|string[]|LazyPlugin[]
159159
---@param reason {[string]:string}
160-
function M.load(plugins, reason)
160+
---@param opts? {force:boolean} when force is true, we skip the cond check
161+
function M.load(plugins, reason, opts)
161162
---@diagnostic disable-next-line: cast-local-type
162163
plugins = (type(plugins) == "string" or plugins.name) and { plugins } or plugins
163164
---@cast plugins (string|LazyPlugin)[]
@@ -174,19 +175,20 @@ function M.load(plugins, reason)
174175
end
175176
end
176177
if plugin and not plugin._.loaded then
177-
M._load(plugin, reason)
178+
M._load(plugin, reason, opts)
178179
end
179180
end
180181
end
181182

182183
---@param plugin LazyPlugin
183184
---@param reason {[string]:string}
184-
function M._load(plugin, reason)
185+
---@param opts? {force:boolean} when force is true, we skip the cond check
186+
function M._load(plugin, reason, opts)
185187
if not plugin._.installed then
186188
return Util.error("Plugin " .. plugin.name .. " is not installed")
187189
end
188190

189-
if plugin.cond ~= nil then
191+
if plugin.cond ~= nil and not (opts and opts.force) then
190192
if plugin.cond == false or (type(plugin.cond) == "function" and not plugin.cond()) then
191193
plugin._.cond = false
192194
return

lua/lazy/view/commands.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ M.commands = {
5050
end,
5151
---@param opts ManagerOpts
5252
load = function(opts)
53-
require("lazy.core.loader").load(opts.plugins, { cmd = "LazyLoad" })
53+
-- when a command is executed with a bang, wait will be set
54+
require("lazy.core.loader").load(opts.plugins, { cmd = "Lazy load" }, { force = opts.wait })
5455
end,
5556
log = Manage.log,
5657
build = Manage.build,

lua/lazy/view/config.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ M.commands = {
130130
id = 12,
131131
},
132132
load = {
133-
desc = "Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim`",
133+
desc = "Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim`. Use `:Lazy! load` to skip `cond` checks.",
134134
id = 13,
135135
plugins = true,
136136
plugins_required = true,

0 commit comments

Comments
 (0)