mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
fix(build): allow build
command to override plugin's build and option to disable warning
This commit is contained in:
parent
de0a911ad9
commit
189371c8d8
3 changed files with 25 additions and 8 deletions
|
@ -150,6 +150,12 @@ M.defaults = {
|
|||
skip_if_doc_exists = true,
|
||||
},
|
||||
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,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
local Util = require("lazy.util")
|
||||
local Loader = require("lazy.core.loader")
|
||||
local Config = require("lazy.core.config")
|
||||
|
||||
---@type table<string, LazyTaskDef>
|
||||
local M = {}
|
||||
|
@ -32,14 +33,17 @@ M.build = {
|
|||
local build_file = get_build_file(self.plugin)
|
||||
if build_file then
|
||||
if builders then
|
||||
Util.warn(
|
||||
("Plugin **%s** provides its own build script.\nPlease remove the `build` option from the plugin's spec"):format(
|
||||
self.plugin.name
|
||||
if Config.options.build.warn_on_override then
|
||||
Util.warn(
|
||||
("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
|
||||
builders = function()
|
||||
Loader.source(build_file)
|
||||
end
|
||||
else
|
||||
builders = function()
|
||||
Loader.source(build_file)
|
||||
end
|
||||
end
|
||||
end
|
||||
if builders then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue