mirror of https://github.com/folke/lazy.nvim.git
fix(build): allow `build` command to override plugin's build and option to disable warning
This commit is contained in:
parent
de0a911ad9
commit
189371c8d8
|
@ -306,7 +306,7 @@ return {
|
||||||
-- leave nil when passing the spec as the first argument to setup()
|
-- leave nil when passing the spec as the first argument to setup()
|
||||||
spec = nil, ---@type LazySpec
|
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 = jit.os:find("Windows") and (vim.loop.available_parallelism() * 2) or nil, ---@type number limit the maximum amount of concurrent tasks
|
||||||
git = {
|
git = {
|
||||||
-- defaults for the `Lazy log` command
|
-- defaults for the `Lazy log` command
|
||||||
-- log = { "-10" }, -- show the last 10 commits
|
-- log = { "-10" }, -- show the last 10 commits
|
||||||
|
@ -439,6 +439,12 @@ return {
|
||||||
skip_if_doc_exists = true,
|
skip_if_doc_exists = true,
|
||||||
},
|
},
|
||||||
state = vim.fn.stdpath("state") .. "/lazy/state.json", -- state info for checker and other things
|
state = vim.fn.stdpath("state") .. "/lazy/state.json", -- state info for checker and other things
|
||||||
|
build = {
|
||||||
|
-- Plugins can provide a `build.lua` file that will be executed when the plugin is installed
|
||||||
|
-- or updated. When the plugin spec also has a `build` command, the plugin's `build.lua` not be
|
||||||
|
-- executed. In this case, a warning message will be shown.
|
||||||
|
warn_on_override = true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -500,6 +506,7 @@ Any operation can be started from the UI, with a sub command or an API function:
|
||||||
| `: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 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 reload {plugins}` | `require("lazy").reload(opts)` | Reload a plugin (experimental!!) |
|
||||||
| `: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 |
|
||||||
| `:Lazy sync [plugins]` | `require("lazy").sync(opts?)` | Run install, clean and update |
|
| `:Lazy sync [plugins]` | `require("lazy").sync(opts?)` | Run install, clean and update |
|
||||||
| `:Lazy update [plugins]` | `require("lazy").update(opts?)` | Update plugins. This will also update the lockfile |
|
| `:Lazy update [plugins]` | `require("lazy").update(opts?)` | Update plugins. This will also update the lockfile |
|
||||||
|
|
|
@ -150,6 +150,12 @@ M.defaults = {
|
||||||
skip_if_doc_exists = true,
|
skip_if_doc_exists = true,
|
||||||
},
|
},
|
||||||
state = vim.fn.stdpath("state") .. "/lazy/state.json", -- state info for checker and other things
|
state = vim.fn.stdpath("state") .. "/lazy/state.json", -- state info for checker and other things
|
||||||
|
build = {
|
||||||
|
-- Plugins can provide a `build.lua` file that will be executed when the plugin is installed
|
||||||
|
-- or updated. When the plugin spec also has a `build` command, the plugin's `build.lua` not be
|
||||||
|
-- executed. In this case, a warning message will be shown.
|
||||||
|
warn_on_override = true,
|
||||||
|
},
|
||||||
debug = false,
|
debug = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
local Util = require("lazy.util")
|
local Util = require("lazy.util")
|
||||||
local Loader = require("lazy.core.loader")
|
local Loader = require("lazy.core.loader")
|
||||||
|
local Config = require("lazy.core.config")
|
||||||
|
|
||||||
---@type table<string, LazyTaskDef>
|
---@type table<string, LazyTaskDef>
|
||||||
local M = {}
|
local M = {}
|
||||||
|
@ -32,14 +33,17 @@ M.build = {
|
||||||
local build_file = get_build_file(self.plugin)
|
local build_file = get_build_file(self.plugin)
|
||||||
if build_file then
|
if build_file then
|
||||||
if builders then
|
if builders then
|
||||||
Util.warn(
|
if Config.options.build.warn_on_override then
|
||||||
("Plugin **%s** provides its own build script.\nPlease remove the `build` option from the plugin's spec"):format(
|
Util.warn(
|
||||||
self.plugin.name
|
("Plugin **%s** provides its own build script, but you also defined a `build` command.\nThe `build.lua` file will not be used"):format(
|
||||||
|
self.plugin.name
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
end
|
||||||
end
|
else
|
||||||
builders = function()
|
builders = function()
|
||||||
Loader.source(build_file)
|
Loader.source(build_file)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if builders then
|
if builders then
|
||||||
|
|
Loading…
Reference in New Issue