refactor(nvim): improve handling of image.nvim installation failure

This commit is contained in:
Price Hiller 2023-10-24 04:31:43 -05:00
parent 1d8f8f86f8
commit 3b65549788
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8

View File

@ -5,10 +5,16 @@ return {
---@type vim.SystemCompleted
local out = vim.system({ "luarocks", "--lua-version", "5.1", "--local", "install", "magick" }):wait()
if out.code ~= 0 then
-- Delete it to ensure this builder script is ran again on next update/sync/etc.
vim.fn.delete(vim.fn.stdpath("data") .. "/lazy/image.nvim", "rf")
error(
string.format(
"Failed to install `magick` luarock for image.nvim!\n---STDOUT---\n%s\n\n---STDERR---\n\n%s", out.stdout,
out.stderr), vim.log.levels.ERROR)
string.format(
"Failed to install `magick` luarock for image.nvim!\n---STDOUT---\n%s\n\n---STDERR---\n\n%s",
out.stdout,
out.stderr
),
vim.log.levels.ERROR
)
end
end,
ft = { "markdown", "norg" },