No description
Find a file
Barrett Ruth 39406c559c
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
2026-03-06 14:58:10 -05:00
.github/workflows ci: format 2026-03-01 17:22:59 -05:00
doc feat: compile notifications and long-running provider feedback (#55) 2026-03-06 14:58:10 -05:00
lua/preview feat: compile notifications and long-running provider feedback (#55) 2026-03-06 14:58:10 -05:00
plugin feat: rename 2026-03-02 21:23:40 -05:00
scripts fix(ci): use absolute path for lua-language-server --configpath (#34) 2026-03-04 14:33:25 -05:00
spec feat: compile notifications and long-running provider feedback (#55) 2026-03-06 14:58:10 -05:00
.busted ci: format 2026-03-01 17:22:59 -05:00
.editorconfig ci: format 2026-03-01 17:22:59 -05:00
.gitignore ci: format 2026-03-01 17:22:59 -05:00
.luarc.json fix(ci): resolve lua-language-server warnings (#32) 2026-03-04 14:28:52 -05:00
.prettierrc ci: format 2026-03-01 17:22:59 -05:00
.styluaignore ci: scripts (#31) 2026-03-04 14:23:38 -05:00
flake.lock ci: format 2026-03-01 17:22:59 -05:00
flake.nix docs: add SyncTeX section with viewer recipes (#50) 2026-03-05 22:39:26 -05:00
LICENSE ci: format 2026-03-01 17:22:59 -05:00
preview.nvim-scm-1.rockspec feat: rename 2026-03-02 21:23:40 -05:00
README.md docs: add SyncTeX section with viewer recipes (#50) 2026-03-05 22:39:26 -05:00
selene.toml ci: format 2026-03-01 17:25:34 -05:00
stylua.toml ci: format 2026-03-01 17:22:59 -05:00
vim.yaml ci: format 2026-03-01 17:22:59 -05:00

preview.nvim

Universal previewer for Neovim

An extensible framework for compiling and previewing any documents (LaTeX, Typst, Markdown, etc.)—diagnostics included.

Features

  • Async compilation via vim.system()
  • Built-in presets for Typst, LaTeX (latexmk, pdflatex, tectonic), Markdown, GitHub-flavored Markdown, AsciiDoc, PlantUML, Mermaid, and Quarto
  • Compiler errors via vim.diagnostic or quickfix
  • Previewer auto-close on buffer deletion

Requirements

  • Neovim 0.11+

Installation

With lazy.nvim:

{
  'barrettruth/preview.nvim',
  init = function()
    vim.g.preview = { typst = true, latex = true }
  end,
}

Or via luarocks:

luarocks install preview.nvim

Documentation

:help preview.nvim

FAQ

Q: How do I define a custom provider?

vim.g.preview = {
  rst = {
    cmd = { 'rst2html' },
    args = function(ctx)
      return { ctx.file, ctx.output }
    end,
    output = function(ctx)
      return ctx.file:gsub('%.rst$', '.html')
    end,
  },
}

Q: How do I override a preset?

vim.g.preview = {
  typst = { env = { TYPST_FONT_PATHS = '/usr/share/fonts' } },
}

Q: How do I automatically open the output file?

Set open = true on your provider (all built-in presets have this enabled) to open the output with vim.ui.open() after the first successful compilation in toggle/watch mode. For a specific application, pass a command table:

vim.g.preview = {
  typst = { open = { 'sioyek', '--new-instance' } },
}

Q: How do I set up SyncTeX (forward/inverse search)?

See :help preview-synctex for full recipes covering Zathura, Sioyek, and Okular.