mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-06-28 11:24:14 +00:00
fix(rocks): better errors / warnings when something goes wrong with luarocks
This commit is contained in:
parent
9005e8ede7
commit
7d3f69104f
11 changed files with 336 additions and 141 deletions
|
@ -12,6 +12,7 @@ local Process = require("lazy.manage.process")
|
|||
---@field output string
|
||||
---@field status string
|
||||
---@field error? string
|
||||
---@field warn? string
|
||||
---@field private _task fun(task:LazyTask)
|
||||
---@field private _running LazyPluginState[]
|
||||
---@field private _started? number
|
||||
|
@ -74,6 +75,30 @@ function Task:start()
|
|||
self:_check()
|
||||
end
|
||||
|
||||
---@param msg string|string[]
|
||||
---@param severity? vim.diagnostic.Severity
|
||||
function Task:notify(msg, severity)
|
||||
local var = severity == vim.diagnostic.severity.ERROR and "error"
|
||||
or severity == vim.diagnostic.severity.WARN and "warn"
|
||||
or "output"
|
||||
msg = type(msg) == "table" and table.concat(msg, "\n") or msg
|
||||
---@cast msg string
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
self[var] = self[var] and (self[var] .. "\n" .. msg) or msg
|
||||
self.status = msg
|
||||
vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
|
||||
end
|
||||
|
||||
---@param msg string|string[]
|
||||
function Task:notify_error(msg)
|
||||
self:notify(msg, vim.diagnostic.severity.ERROR)
|
||||
end
|
||||
|
||||
---@param msg string|string[]
|
||||
function Task:notify_warn(msg)
|
||||
self:notify(msg, vim.diagnostic.severity.WARN)
|
||||
end
|
||||
|
||||
---@param fn async fun()
|
||||
function Task:async(fn)
|
||||
local co = coroutine.create(fn)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue