From a2ef9a828f0bddaa415e18669eed7f498d1e98b9 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Wed, 4 Mar 2026 14:48:12 -0500 Subject: [PATCH 1/2] fix(presets): add --failure-level ERROR to asciidoctor args Problem: asciidoctor exits 0 even when it encounters ERROR-level messages, so the compiler treats every run as a success and never invokes error_parser. Errors are silently embedded as visible text in the HTML output instead of surfacing as diagnostics. Solution: pass --failure-level ERROR so asciidoctor exits non-zero on errors, which triggers error_parser and surfaces diagnostics. --- lua/preview/presets.lua | 2 +- spec/presets_spec.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/preview/presets.lua b/lua/preview/presets.lua index 8a23766..30693ff 100644 --- a/lua/preview/presets.lua +++ b/lua/preview/presets.lua @@ -246,7 +246,7 @@ M.asciidoctor = { ft = 'asciidoc', cmd = { 'asciidoctor' }, args = function(ctx) - return { ctx.file, '-o', ctx.output } + return { '--failure-level', 'ERROR', ctx.file, '-o', ctx.output } end, output = function(ctx) return (ctx.file:gsub('%.adoc$', '.html')) diff --git a/spec/presets_spec.lua b/spec/presets_spec.lua index ab030f0..9259d5a 100644 --- a/spec/presets_spec.lua +++ b/spec/presets_spec.lua @@ -467,7 +467,7 @@ describe('presets', function() it('returns args with file and output', function() assert.are.same( - { '/tmp/document.adoc', '-o', '/tmp/document.html' }, + { '--failure-level', 'ERROR', '/tmp/document.adoc', '-o', '/tmp/document.html' }, presets.asciidoctor.args(adoc_ctx) ) end) From 454030ad78642083e0cc372b49153af4c763c506 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Wed, 4 Mar 2026 14:51:14 -0500 Subject: [PATCH 2/2] fix(compiler): do not auto-open on one-shot compile Problem: auto-open fired on :Preview compile, which is a one-shot build. Users compiling to check for errors or rebuild with the viewer already open got an unexpected browser/viewer window. Solution: gate auto-open on not opts.oneshot so it only fires during toggle/watch mode, where opening the viewer on first compile is the intended behaviour. --- lua/preview/compiler.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/preview/compiler.lua b/lua/preview/compiler.lua index 74d6070..38a048e 100644 --- a/lua/preview/compiler.lua +++ b/lua/preview/compiler.lua @@ -162,6 +162,7 @@ function M.compile(bufnr, name, provider, ctx, opts) if provider.open + and not opts.oneshot and not opened[bufnr] and output_file ~= '' and vim.uv.fs_stat(output_file) @@ -240,6 +241,7 @@ function M.compile(bufnr, name, provider, ctx, opts) end if provider.open + and not opts.oneshot and not opened[bufnr] and output_file ~= '' and vim.uv.fs_stat(output_file)