2022-11-28 10:04:32 +00:00
|
|
|
local Util = require("lazy.util")
|
|
|
|
local Loader = require("lazy.core.loader")
|
|
|
|
|
|
|
|
---@type table<string, LazyTaskDef>
|
|
|
|
local M = {}
|
|
|
|
|
2022-12-01 06:43:28 +00:00
|
|
|
M.build = {
|
2022-11-28 12:11:20 +00:00
|
|
|
skip = function(plugin)
|
2022-12-01 06:43:28 +00:00
|
|
|
return not (plugin._.dirty and (plugin.opt == false or plugin.build))
|
2022-11-28 10:04:32 +00:00
|
|
|
end,
|
|
|
|
run = function(self)
|
|
|
|
Loader.load(self.plugin, { task = "run" }, { load_start = true })
|
|
|
|
|
2022-12-01 06:43:28 +00: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 10:04:32 +00:00
|
|
|
self.output = vim.api.nvim_cmd(cmd, { output = true })
|
2022-12-01 06:43:28 +00:00
|
|
|
elseif type(build) == "function" then
|
|
|
|
build()
|
2022-11-28 10:04:32 +00:00
|
|
|
else
|
2022-12-01 06:43:28 +00:00
|
|
|
local args = vim.split(build, "%s+")
|
2022-11-28 10:04:32 +00:00
|
|
|
return self:spawn(table.remove(args, 1), {
|
|
|
|
args = args,
|
|
|
|
cwd = self.plugin.dir,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
|
|
|
M.docs = {
|
2022-11-28 12:11:20 +00:00
|
|
|
skip = function(plugin)
|
|
|
|
return not plugin._.dirty
|
2022-11-28 10:04:32 +00: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
|