fix(presets): add --failure-level ERROR to asciidoctor, add clean to typst/pdflatex/tectonic, skip auto-open on one-shot compile (#35)
Problem: asciidoctor exits 0 on errors so error_parser never ran. typst, pdflatex, and tectonic had no clean subcommand. auto-open fired on :Preview compile, surprising users who just want a build. Solution: pass --failure-level ERROR in asciidoctor args. Add clean commands to typst (rm pdf), pdflatex (rm pdf/aux/log/synctex.gz), and tectonic (rm pdf). Gate auto-open on not opts.oneshot so it only fires during toggle/watch mode.
This commit is contained in:
parent
d4e7d8c2fd
commit
68e2e82232
3 changed files with 30 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -128,6 +128,9 @@ M.typst = {
|
|||
error_parser = function(output)
|
||||
return parse_typst(output)
|
||||
end,
|
||||
clean = function(ctx)
|
||||
return { 'rm', '-f', (ctx.file:gsub('%.typ$', '.pdf')) }
|
||||
end,
|
||||
open = true,
|
||||
reload = function(ctx)
|
||||
return { 'typst', 'watch', ctx.file }
|
||||
|
|
@ -172,6 +175,10 @@ M.pdflatex = {
|
|||
error_parser = function(output)
|
||||
return parse_latexmk(output)
|
||||
end,
|
||||
clean = function(ctx)
|
||||
local base = ctx.file:gsub('%.tex$', '')
|
||||
return { 'rm', '-f', base .. '.pdf', base .. '.aux', base .. '.log', base .. '.synctex.gz' }
|
||||
end,
|
||||
open = true,
|
||||
}
|
||||
|
||||
|
|
@ -188,6 +195,9 @@ M.tectonic = {
|
|||
error_parser = function(output)
|
||||
return parse_latexmk(output)
|
||||
end,
|
||||
clean = function(ctx)
|
||||
return { 'rm', '-f', (ctx.file:gsub('%.tex$', '.pdf')) }
|
||||
end,
|
||||
open = true,
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +256,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'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue