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:
parent
1456b3070a
commit
781a9c4818
2 changed files with 37 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue