fix(compiler): resolve output into ctx before evaluating clean command

Problem: M.clean() passes the raw ctx (no output field) to the
provider's clean function. Built-in presets work around this by
recomputing the output path inline, but custom providers using
ctx.output in their clean function receive nil.

Solution: resolve output_file from provider.output before eval, extend
ctx into resolved_ctx with the output field, and use resolved_ctx when
evaluating clean and cwd — consistent with how M.compile() handles args.
This commit is contained in:
Barrett Ruth 2026-03-03 17:49:23 -05:00
parent 2888c5bb09
commit ea783e9983
Signed by: barrett
GPG key ID: A6C96C9349D2FC81

View file

@ -396,10 +396,16 @@ function M.clean(bufnr, name, provider, ctx)
return
end
local cmd = eval_list(provider.clean, ctx)
local cwd = ctx.root
local output_file = ''
if provider.output then
output_file = eval_string(provider.output, ctx)
end
local resolved_ctx = vim.tbl_extend('force', ctx, { output = output_file })
local cmd = eval_list(provider.clean, resolved_ctx)
local cwd = resolved_ctx.root
if provider.cwd then
cwd = eval_string(provider.cwd, ctx)
cwd = eval_string(provider.cwd, resolved_ctx)
end
log.dbg('cleaning buffer %d with provider "%s": %s', bufnr, name, table.concat(cmd, ' '))