fix(presets): correct error parsers for real compiler output

Problem: all three built-in error parsers were broken against real
compiler output. Typst set source to the relative file path, overriding
the provider name. LaTeX errors go to stdout but the parser only
received stderr. Pandoc's pattern matched "Error at" but not the real
"Error parsing YAML metadata at" format, and single-line parsing missed
multiline messages.

Solution: pass combined stdout+stderr to error_parser so LaTeX stdout
errors are visible. Remove source = file from the Typst parser so
diagnostic.lua defaults it to the provider name. Rewrite the Pandoc
parser with line-based lookahead: match (line N, column N) regardless
of prefix text, skip YAML parse exception lines when looking ahead for
the human-readable message. Rename stderr param to output throughout
diagnostic.lua, presets.lua, and init.lua annotations.
This commit is contained in:
Barrett Ruth 2026-03-03 14:07:00 -05:00
parent 87fc00059c
commit 56d110a74e
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
5 changed files with 101 additions and 79 deletions

View file

@ -12,11 +12,11 @@ end
---@param bufnr integer
---@param name string
---@param error_parser fun(stderr: string, ctx: preview.Context): preview.Diagnostic[]
---@param stderr string
---@param error_parser fun(output: string, ctx: preview.Context): preview.Diagnostic[]
---@param output string
---@param ctx preview.Context
function M.set(bufnr, name, error_parser, stderr, ctx)
local ok, diagnostics = pcall(error_parser, stderr, ctx)
function M.set(bufnr, name, error_parser, output, ctx)
local ok, diagnostics = pcall(error_parser, output, ctx)
if not ok then
log.dbg('error_parser for "%s" failed: %s', name, diagnostics)
return