fix(compiler): check executable before spawning process

Problem: if a configured binary was missing or not in PATH, vim.system
would fail silently or with a cryptic OS error. The user had no
actionable feedback without running :checkhealth.

Solution: check vim.fn.executable() at the start of M.compile() and
notify with an ERROR-level message pointing to :checkhealth preview
if the binary is not found.
This commit is contained in:
Barrett Ruth 2026-03-04 13:50:06 -05:00
parent 1456b3070a
commit 781a9c4818
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
2 changed files with 37 additions and 0 deletions

View file

@ -58,6 +58,14 @@ end
function M.compile(bufnr, name, provider, ctx, opts)
opts = opts or {}
if vim.fn.executable(provider.cmd[1]) ~= 1 then
vim.notify(
'[preview.nvim]: "' .. provider.cmd[1] .. '" is not executable (run :checkhealth preview)',
vim.log.levels.ERROR
)
return
end
if vim.bo[bufnr].modified then
vim.cmd('silent! update')
end