refactor: move task too manage.task

This commit is contained in:
Folke Lemaitre 2022-11-28 07:35:58 +01:00
parent f54c24a4fa
commit 02f5528aa3
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 7 additions and 3 deletions

View File

@ -12,6 +12,7 @@ local Task = {}
---@alias TaskType "update"|"install"|"run"|"clean"|"log"|"docs" ---@alias TaskType "update"|"install"|"run"|"clean"|"log"|"docs"
---@class TaskOptions ---@class TaskOptions
---@field on_done? fun(task:LazyTask)
local options = { local options = {
log = { log = {
since = "7 days ago", since = "7 days ago",
@ -41,6 +42,9 @@ end
function Task:_done() function Task:_done()
self.running = false self.running = false
if self.opts.on_done then
self.opts.on_done(self)
end
vim.cmd("do User LazyRender") vim.cmd("do User LazyRender")
vim.api.nvim_exec_autocmds("User", { vim.api.nvim_exec_autocmds("User", {
pattern = "LazyPlugin" .. self.type:sub(1, 1):upper() .. self.type:sub(2), pattern = "LazyPlugin" .. self.type:sub(1, 1):upper() .. self.type:sub(2),
@ -81,8 +85,8 @@ function Task:install()
"clone", "clone",
self.plugin.uri, self.plugin.uri,
-- "--depth=1", -- "--depth=1",
-- "--filter=blob:none", "--filter=blob:none",
"--filter=tree:0", -- "--filter=tree:0",
"--recurse-submodules", "--recurse-submodules",
"--single-branch", "--single-branch",
"--shallow-submodules", "--shallow-submodules",
@ -127,7 +131,7 @@ function Task:run()
}) })
end end
end end
-- FIXME: the spawn above wont be finished yet
self:_done() self:_done()
end end