mirror of https://github.com/folke/lazy.nvim.git
feat(commands): `:Lazy! load` now skips `cond` checks when loading plugins. Fixes #330
This commit is contained in:
parent
2ef44e2dee
commit
eed1ef3c2d
28
README.md
28
README.md
|
@ -303,6 +303,8 @@ return {
|
||||||
version = nil,
|
version = nil,
|
||||||
-- version = "*", -- enable this to try installing the latest stable versions of plugins
|
-- version = "*", -- enable this to try installing the latest stable versions of plugins
|
||||||
},
|
},
|
||||||
|
-- leave nil when passing the spec as the first argument to setup()
|
||||||
|
spec = nil, ---@type LazySpec
|
||||||
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
|
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
|
||||||
concurrency = nil, ---@type number limit the maximum amount of concurrent tasks
|
concurrency = nil, ---@type number limit the maximum amount of concurrent tasks
|
||||||
git = {
|
git = {
|
||||||
|
@ -330,20 +332,21 @@ return {
|
||||||
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
|
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
|
||||||
border = "none",
|
border = "none",
|
||||||
icons = {
|
icons = {
|
||||||
loaded = "●",
|
|
||||||
not_loaded = "○",
|
|
||||||
cmd = " ",
|
cmd = " ",
|
||||||
config = "",
|
config = "",
|
||||||
event = "",
|
event = "",
|
||||||
ft = " ",
|
ft = " ",
|
||||||
init = " ",
|
init = " ",
|
||||||
|
import = " ",
|
||||||
keys = " ",
|
keys = " ",
|
||||||
|
lazy = "鈴 ",
|
||||||
|
loaded = "●",
|
||||||
|
not_loaded = "○",
|
||||||
plugin = " ",
|
plugin = " ",
|
||||||
runtime = " ",
|
runtime = " ",
|
||||||
source = " ",
|
source = " ",
|
||||||
start = "",
|
start = "",
|
||||||
task = "✔ ",
|
task = "✔ ",
|
||||||
lazy = "鈴 ",
|
|
||||||
list = {
|
list = {
|
||||||
"●",
|
"●",
|
||||||
"➜",
|
"➜",
|
||||||
|
@ -361,21 +364,15 @@ return {
|
||||||
|
|
||||||
-- open lazygit log
|
-- open lazygit log
|
||||||
["<localleader>l"] = function(plugin)
|
["<localleader>l"] = function(plugin)
|
||||||
require("lazy.util").open_cmd({ "lazygit", "log" }, {
|
require("lazy.util").float_term({ "lazygit", "log" }, {
|
||||||
cwd = plugin.dir,
|
cwd = plugin.dir,
|
||||||
terminal = true,
|
|
||||||
close_on_exit = true,
|
|
||||||
enter = true,
|
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- open a terminal for the plugin dir
|
-- open a terminal for the plugin dir
|
||||||
["<localleader>t"] = function(plugin)
|
["<localleader>t"] = function(plugin)
|
||||||
require("lazy.util").open_cmd({ vim.go.shell }, {
|
require("lazy.util").float_term(nil, {
|
||||||
cwd = plugin.dir,
|
cwd = plugin.dir,
|
||||||
terminal = true,
|
|
||||||
close_on_exit = true,
|
|
||||||
enter = true,
|
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
@ -410,7 +407,7 @@ return {
|
||||||
-- The default is to disable on:
|
-- The default is to disable on:
|
||||||
-- * VimEnter: not useful to cache anything else beyond startup
|
-- * VimEnter: not useful to cache anything else beyond startup
|
||||||
-- * BufReadPre: this will be triggered early when opening a file from the command line directly
|
-- * BufReadPre: this will be triggered early when opening a file from the command line directly
|
||||||
disable_events = { "VimEnter", "BufReadPre" },
|
disable_events = { "UIEnter", "BufReadPre" },
|
||||||
ttl = 3600 * 24 * 5, -- keep unused modules for up to 5 days
|
ttl = 3600 * 24 * 5, -- keep unused modules for up to 5 days
|
||||||
},
|
},
|
||||||
reset_packpath = true, -- reset the package path to improve startup time
|
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:
|
||||||
| `:Lazy help` | `require("lazy").help()` | Toggle this help page |
|
| `:Lazy help` | `require("lazy").help()` | Toggle this help page |
|
||||||
| `:Lazy home` | `require("lazy").home()` | Go back to plugin list |
|
| `:Lazy home` | `require("lazy").home()` | Go back to plugin list |
|
||||||
| `:Lazy install [plugins]` | `require("lazy").install(opts?)` | Install missing plugins |
|
| `:Lazy install [plugins]` | `require("lazy").install(opts?)` | Install missing plugins |
|
||||||
| `:Lazy load {plugins}` | `require("lazy").load(opts)` | Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim` |
|
| `: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. |
|
||||||
| `:Lazy log [plugins]` | `require("lazy").log(opts?)` | Show recent updates |
|
| `:Lazy log [plugins]` | `require("lazy").log(opts?)` | Show recent updates |
|
||||||
| `:Lazy profile` | `require("lazy").profile()` | Show detailed profiling |
|
| `:Lazy profile` | `require("lazy").profile()` | Show detailed profiling |
|
||||||
| `: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 |
|
| `: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()`):
|
||||||
-- when true, startuptime is the accurate cputime for the Neovim process. (Linux & Macos)
|
-- when true, startuptime is the accurate cputime for the Neovim process. (Linux & Macos)
|
||||||
-- this is more accurate than `nvim --startuptime`, and as such will be slightly higher
|
-- this is more accurate than `nvim --startuptime`, and as such will be slightly higher
|
||||||
-- when false, startuptime is calculated based on a delta with a timestamp when lazy started.
|
-- when false, startuptime is calculated based on a delta with a timestamp when lazy started.
|
||||||
startuptime_cputime = false,
|
real_cputime = false,
|
||||||
count = 0, -- total number of plugins
|
count = 0, -- total number of plugins
|
||||||
loaded = 0, -- number of loaded plugins
|
loaded = 0, -- number of loaded plugins
|
||||||
|
---@type table<string, number>
|
||||||
|
times = {},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -738,6 +737,7 @@ To uninstall **lazy.nvim**, you need to remove the following files and directori
|
||||||
| **LazyReasonCmd** | **_Operator_** | |
|
| **LazyReasonCmd** | **_Operator_** | |
|
||||||
| **LazyReasonEvent** | **_Constant_** | |
|
| **LazyReasonEvent** | **_Constant_** | |
|
||||||
| **LazyReasonFt** | **_Character_** | |
|
| **LazyReasonFt** | **_Character_** | |
|
||||||
|
| **LazyReasonImport** | **_Identifier_** | |
|
||||||
| **LazyReasonKeys** | **_Statement_** | |
|
| **LazyReasonKeys** | **_Statement_** | |
|
||||||
| **LazyReasonPlugin** | **_Special_** | |
|
| **LazyReasonPlugin** | **_Special_** | |
|
||||||
| **LazyReasonRuntime** | **_@macro_** | |
|
| **LazyReasonRuntime** | **_@macro_** | |
|
||||||
|
|
|
@ -157,7 +157,8 @@ end
|
||||||
---@class Loader
|
---@class Loader
|
||||||
---@param plugins string|LazyPlugin|string[]|LazyPlugin[]
|
---@param plugins string|LazyPlugin|string[]|LazyPlugin[]
|
||||||
---@param reason {[string]:string}
|
---@param reason {[string]:string}
|
||||||
function M.load(plugins, reason)
|
---@param opts? {force:boolean} when force is true, we skip the cond check
|
||||||
|
function M.load(plugins, reason, opts)
|
||||||
---@diagnostic disable-next-line: cast-local-type
|
---@diagnostic disable-next-line: cast-local-type
|
||||||
plugins = (type(plugins) == "string" or plugins.name) and { plugins } or plugins
|
plugins = (type(plugins) == "string" or plugins.name) and { plugins } or plugins
|
||||||
---@cast plugins (string|LazyPlugin)[]
|
---@cast plugins (string|LazyPlugin)[]
|
||||||
|
@ -174,19 +175,20 @@ function M.load(plugins, reason)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if plugin and not plugin._.loaded then
|
if plugin and not plugin._.loaded then
|
||||||
M._load(plugin, reason)
|
M._load(plugin, reason, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
---@param reason {[string]:string}
|
---@param reason {[string]:string}
|
||||||
function M._load(plugin, reason)
|
---@param opts? {force:boolean} when force is true, we skip the cond check
|
||||||
|
function M._load(plugin, reason, opts)
|
||||||
if not plugin._.installed then
|
if not plugin._.installed then
|
||||||
return Util.error("Plugin " .. plugin.name .. " is not installed")
|
return Util.error("Plugin " .. plugin.name .. " is not installed")
|
||||||
end
|
end
|
||||||
|
|
||||||
if plugin.cond ~= nil then
|
if plugin.cond ~= nil and not (opts and opts.force) then
|
||||||
if plugin.cond == false or (type(plugin.cond) == "function" and not plugin.cond()) then
|
if plugin.cond == false or (type(plugin.cond) == "function" and not plugin.cond()) then
|
||||||
plugin._.cond = false
|
plugin._.cond = false
|
||||||
return
|
return
|
||||||
|
|
|
@ -50,7 +50,8 @@ M.commands = {
|
||||||
end,
|
end,
|
||||||
---@param opts ManagerOpts
|
---@param opts ManagerOpts
|
||||||
load = function(opts)
|
load = function(opts)
|
||||||
require("lazy.core.loader").load(opts.plugins, { cmd = "LazyLoad" })
|
-- when a command is executed with a bang, wait will be set
|
||||||
|
require("lazy.core.loader").load(opts.plugins, { cmd = "Lazy load" }, { force = opts.wait })
|
||||||
end,
|
end,
|
||||||
log = Manage.log,
|
log = Manage.log,
|
||||||
build = Manage.build,
|
build = Manage.build,
|
||||||
|
|
|
@ -130,7 +130,7 @@ M.commands = {
|
||||||
id = 12,
|
id = 12,
|
||||||
},
|
},
|
||||||
load = {
|
load = {
|
||||||
desc = "Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim`",
|
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.",
|
||||||
id = 13,
|
id = 13,
|
||||||
plugins = true,
|
plugins = true,
|
||||||
plugins_required = true,
|
plugins_required = true,
|
||||||
|
|
Loading…
Reference in New Issue