feat: compile notifications and long-running provider feedback (#55)

* feat(compiler): add compile start/complete notifications

Problem: No user-facing feedback when compilation starts or finishes.
Long-running compilers like pandoc with `--embed-resources` leave the
user staring at nothing for 15+ seconds.

Solution: Notify "compiling..." at compile start and "compilation
complete" on success. The initial `toggle` call uses a combined
"compiling with <name>..." message to avoid stacking two notifications.

* refactor(presets): use `--katex` instead of `--embed-resources --mathml`

Problem: `--embed-resources` with `--mathml` caused pandoc to inline all
assets at compile time, adding ~15s per save for KaTeX-heavy documents.

Solution: Default to `--katex`, which inserts a CDN `<script>` tag and
defers rendering to the browser. Users can opt into `--embed-resources`
or `--mathml` via `extra_args`.

* docs(presets): rewrite math rendering section for `--katex` default

* refactor(compiler): simplify notification flow, add failure notify

Problem: `compile()` used an `opts.silent` escape hatch so `toggle()`
could suppress duplicate notifications. Compilation failures had no
user-facing notification.

Solution: Remove `opts.silent` — `compile()` unconditionally notifies
on start, success, and failure. `toggle()` no longer emits its own
message.

* feat(compiler): add per-recompile notifications for long-running providers

Problem: long-running providers like `typst watch` had no per-recompile
feedback — the process stays alive and individual success/failure was
never reported.

Solution: add a persistent `output_watcher` fs_event that fires
"compilation complete" on every output mtime bump, and track
`has_errors` on `BufState` so stderr diagnostics trigger a one-shot
"compilation failed" notification. `diagnostic.set()` now returns the
diagnostic count to support this flow.

* ci: format

* chore: remove testing files
This commit is contained in:
Barrett Ruth 2026-03-06 14:58:10 -05:00 committed by GitHub
parent aeea1bd8fa
commit 39406c559c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 217 additions and 44 deletions

View file

@ -294,13 +294,10 @@ describe('presets', function()
assert.are.same({ 'pandoc' }, presets.markdown.cmd)
end)
it('returns args with standalone, embed-resources, and mathml flags', function()
it('returns args with standalone and katex flags', function()
local args = presets.markdown.args(md_ctx)
assert.is_table(args)
assert.are.same(
{ '/tmp/document.md', '-s', '--embed-resources', '--mathml', '-o', '/tmp/document.html' },
args
)
assert.are.same({ '/tmp/document.md', '-s', '--katex', '-o', '/tmp/document.html' }, args)
end)
it('returns html output path', function()
@ -382,7 +379,7 @@ describe('presets', function()
assert.are.same({ 'pandoc' }, presets.github.cmd)
end)
it('returns args with standalone, embed-resources, mathml, and css flags', function()
it('returns args with standalone, katex, and css flags', function()
local args = presets.github.args(md_ctx)
assert.is_table(args)
assert.are.same({
@ -390,8 +387,7 @@ describe('presets', function()
'gfm',
'/tmp/document.md',
'-s',
'--embed-resources',
'--mathml',
'--katex',
'--css',
'https://cdn.jsdelivr.net/gh/pixelbrackets/gfm-stylesheet@master/dist/gfm.css',
'-o',