Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lua/snacks/image/convert.lua
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ local proc_queue = {} ---@type snacks.spawn.Proc[]
local proc_running = 0 ---@type number
local MAX_PROCS = 3

local function has_magick()
if have.magick == nil then
have.magick = vim.fn.executable("magick") == 1 or (not Snacks.util.is_win and vim.fn.executable("convert") == 1)
end
return have.magick
end

---@param proc? snacks.spawn.Proc
local function schedule(proc)
if proc then
Expand Down Expand Up @@ -329,7 +336,7 @@ function Convert:resolve()
self:_resolve("url")
self:_resolve("identify")
end
while self:ft() ~= "png" do
while self:ft() ~= "png" or (#self.steps == 0 and has_magick()) do
local ft = self:ft()
local target = commands[ft] and ft or "convert"
if self:_resolve(target) then
Expand Down
Loading