2022-11-28 18:04:32 +08:00
|
|
|
local Util = require("lazy.util")
|
|
|
|
local Loader = require("lazy.core.loader")
|
|
|
|
|
|
|
|
---@type table<string, LazyTaskDef>
|
|
|
|
local M = {}
|
|
|
|
|
2022-12-01 14:43:28 +08:00
|
|
|
M.build = {
|
2022-11-28 20:11:20 +08:00
|
|
|
skip = function(plugin)
|
2022-12-01 18:06:44 +08:00
|
|
|
return not (plugin._.dirty and plugin.build)
|
2022-11-28 18:04:32 +08:00
|
|
|
end,
|
|
|
|
run = function(self)
|
2022-12-01 18:06:44 +08:00
|
|
|
Loader.load(self.plugin, { task = "build" })
|
2022-12-03 22:48:06 +08:00
|
|
|
-- when installing during startup, add the package
|
|
|
|
-- to make sure all runtime files are loaded
|
|
|
|
Loader.packadd(self.plugin, true)
|
2022-11-28 18:04:32 +08:00
|
|
|
|
2022-12-01 14:43:28 +08:00
|
|
|
local build = self.plugin.build
|
|
|
|
if build then
|
|
|
|
if type(build) == "string" and build:sub(1, 1) == ":" then
|
|
|
|
local cmd = vim.api.nvim_parse_cmd(build:sub(2), {})
|
2022-11-28 18:04:32 +08:00
|
|
|
self.output = vim.api.nvim_cmd(cmd, { output = true })
|
2022-12-01 14:43:28 +08:00
|
|
|
elseif type(build) == "function" then
|
|
|
|
build()
|
2022-11-28 18:04:32 +08:00
|
|
|
else
|
2022-12-01 14:43:28 +08:00
|
|
|
local args = vim.split(build, "%s+")
|
2022-11-28 18:04:32 +08:00
|
|
|
return self:spawn(table.remove(args, 1), {
|
|
|
|
args = args,
|
|
|
|
cwd = self.plugin.dir,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
|
|
|
M.docs = {
|
2022-11-28 20:11:20 +08:00
|
|
|
skip = function(plugin)
|
|
|
|
return not plugin._.dirty
|
2022-11-28 18:04:32 +08:00
|
|
|
end,
|
|
|
|
run = function(self)
|
|
|
|
local docs = self.plugin.dir .. "/doc/"
|
|
|
|
if Util.file_exists(docs) then
|
|
|
|
self.output = vim.api.nvim_cmd({ cmd = "helptags", args = { docs } }, { output = true })
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
|
|
|
return M
|