293 lines · 6.9 KB
---@brief [[
--- glaze.nvim task runner
--- Handles parallel Go binary installation/updates
---@brief ]]

local M = {}

---@class GlazeTask
---@field binary GlazeBinary
---@field status "pending"|"running"|"done"|"error"
---@field output string[]
---@field start_time? number
---@field end_time? number
---@field job_id? number

---@type GlazeTask[]
M._tasks = {}

---@type function?
M._on_update = nil

---@type boolean
M._running = false

---Get all current tasks.
---@return GlazeTask[]
function M.tasks()
  return M._tasks
end

---Check if runner is active.
---@return boolean
function M.is_running()
  return M._running
end

---Set update callback (called when task status changes).
---@param fn function
function M.on_update(fn)
  M._on_update = fn