refactor(presets): add reload field, remove synctex field
Problem: the synctex field only handled PDF forward search and left
HTML live-preview and typst watch mode unsupported.
Solution: add reload = function(ctx) returning { 'typst', 'watch',
ctx.file } to typst (long-running watch mode), reload = true to
markdown and github (SSE push after each pandoc compile), and remove
synctex = true from latex (the -synctex=1 arg in latex.args remains
for .synctex.gz generation).
This commit is contained in:
parent
6c1609cba8
commit
6757c05dd2
2 changed files with 27 additions and 0 deletions
|
|
@ -107,6 +107,9 @@ M.typst = {
|
|||
return parse_typst(output)
|
||||
end,
|
||||
open = true,
|
||||
reload = function(ctx)
|
||||
return { 'typst', 'watch', ctx.file }
|
||||
end,
|
||||
}
|
||||
|
||||
---@type preview.ProviderConfig
|
||||
|
|
@ -117,6 +120,7 @@ M.latex = {
|
|||
return {
|
||||
'-pdf',
|
||||
'-interaction=nonstopmode',
|
||||
'-synctex=1',
|
||||
'-pdflatex=pdflatex -file-line-error -interaction=nonstopmode %O %S',
|
||||
ctx.file,
|
||||
}
|
||||
|
|
@ -150,6 +154,7 @@ M.markdown = {
|
|||
return { 'rm', '-f', (ctx.file:gsub('%.md$', '.html')) }
|
||||
end,
|
||||
open = true,
|
||||
reload = true,
|
||||
}
|
||||
|
||||
---@type preview.ProviderConfig
|
||||
|
|
@ -179,6 +184,7 @@ M.github = {
|
|||
return { 'rm', '-f', (ctx.file:gsub('%.md$', '.html')) }
|
||||
end,
|
||||
open = true,
|
||||
reload = true,
|
||||
}
|
||||
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -37,6 +37,18 @@ describe('presets', function()
|
|||
assert.is_true(presets.typst.open)
|
||||
end)
|
||||
|
||||
it('has reload as a function', function()
|
||||
assert.is_function(presets.typst.reload)
|
||||
end)
|
||||
|
||||
it('reload returns typst watch command', function()
|
||||
local result = presets.typst.reload(ctx)
|
||||
assert.is_table(result)
|
||||
assert.are.equal('typst', result[1])
|
||||
assert.are.equal('watch', result[2])
|
||||
assert.are.equal(ctx.file, result[3])
|
||||
end)
|
||||
|
||||
it('parses errors from stderr', function()
|
||||
local stderr = table.concat({
|
||||
'main.typ:5:23: error: unexpected token',
|
||||
|
|
@ -84,6 +96,7 @@ describe('presets', function()
|
|||
assert.are.same({
|
||||
'-pdf',
|
||||
'-interaction=nonstopmode',
|
||||
'-synctex=1',
|
||||
'-pdflatex=pdflatex -file-line-error -interaction=nonstopmode %O %S',
|
||||
'/tmp/document.tex',
|
||||
}, args)
|
||||
|
|
@ -186,6 +199,10 @@ describe('presets', function()
|
|||
assert.is_true(presets.markdown.open)
|
||||
end)
|
||||
|
||||
it('has reload enabled for SSE', function()
|
||||
assert.is_true(presets.markdown.reload)
|
||||
end)
|
||||
|
||||
it('parses YAML metadata errors with multiline message', function()
|
||||
local output = table.concat({
|
||||
'Error parsing YAML metadata at "/tmp/test.md" (line 1, column 1):',
|
||||
|
|
@ -290,6 +307,10 @@ describe('presets', function()
|
|||
assert.is_true(presets.github.open)
|
||||
end)
|
||||
|
||||
it('has reload enabled for SSE', function()
|
||||
assert.is_true(presets.github.reload)
|
||||
end)
|
||||
|
||||
it('parses YAML metadata errors with multiline message', function()
|
||||
local output = table.concat({
|
||||
'Error parsing YAML metadata at "/tmp/test.md" (line 1, column 1):',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue