universal previewer for neovim
  • Lua 97.4%
  • Shell 0.9%
  • Nix 0.9%
  • HTML 0.6%
  • Just 0.2%
Find a file
Barrett Ruth b98568f401
All checks were successful
quality / Format (push) Successful in 9s
quality / Lint (push) Successful in 7s
quality / Test (push) Successful in 5s
deploy / LuaRocks (nightly) (push) Successful in 59s
docs: add quick start and rename vimdoc (#127)
## Checklist

- [x] I have read [CONTRIBUTING.md](https://git.barrettruth.com/barrettruth/preview.nvim/src/branch/main/CONTRIBUTING.md).
- [ ] No AI was used to generate, edit, or review any part of this contribution.

## Problem

The README and vimdoc still centered the legacy `preview.nvim` help topic, and
the help file kept the `.nvim` suffix in its filename.

## Solution

- Rename the help file to `doc/preview.txt` while preserving legacy help tags.
- Add a concise Quick Start to the README and vimdoc for the common preview loop.
- Prefer `:help preview` and `:help preview-migration` in user-facing pointers.

## Verification

- [x] `git diff --check`
- [x] `vimdoc-language-server format --check doc/`
- [x] `vimdoc-language-server check doc/`
- [x] `stylua --check lua/preview/migration.lua spec/migration_spec.lua`
- [x] `nix develop --command env LUA_PATH='./lua/?.lua;./lua/?/init.lua;./spec/?.lua;;' busted spec/migration_spec.lua`

Reviewed-on: #127
2026-05-09 16:14:32 +00:00
.forgejo docs: add contributing guide (#125) 2026-05-05 17:52:31 +00:00
.github/workflows scaffold Forgejo port for preview.nvim (#117) 2026-05-04 16:46:39 +00:00
doc docs: add quick start and rename vimdoc (#127) 2026-05-09 16:14:32 +00:00
lua/preview docs: add quick start and rename vimdoc (#127) 2026-05-09 16:14:32 +00:00
plugin scaffold Forgejo port for preview.nvim (#117) 2026-05-04 16:46:39 +00:00
spec docs: add quick start and rename vimdoc (#127) 2026-05-09 16:14:32 +00: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
.styluaignore ci: scripts (#31) 2026-03-04 14:23:38 -05:00
biome.json ci: replace prettier with biome (#79) 2026-04-25 14:32:47 -04:00
CONTRIBUTING.md docs: add quick start and rename vimdoc (#127) 2026-05-09 16:14:32 +00:00
flake.lock build(nix): use nixpkgs vimdoc-language-server (#78) 2026-04-20 17:36:30 -04:00
flake.nix ci: replace prettier with biome (#79) 2026-04-25 14:32:47 -04:00
justfile docs: tighten port cleanup blueprint (#119) 2026-05-04 21:16:08 +00:00
LICENSE chore: switch LICENSE to GPLv3 (post-remigrate) 2026-05-01 11:47:38 +00:00
preview.nvim-scm-1.rockspec scaffold Forgejo port for preview.nvim (#117) 2026-05-04 16:46:39 +00:00
README.md docs: add quick start and rename vimdoc (#127) 2026-05-09 16:14:32 +00: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.

Note

Due to GitHub's historic unreliability, active development is hosted on Forgejo. GitHub is maintained as a read-only mirror. See :help preview-migration to optionally update your plugin source configuration.

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
  • Full compiler output via :Preview output
  • Previewer auto-close on buffer deletion

Requirements

  • Neovim 0.11+

Installation

With vim.pack (Neovim 0.12+):

vim.g.preview = { typst = true, latex = true }

vim.pack.add({
  'https://git.barrettruth.com/barrettruth/preview.nvim',
})

Or via luarocks:

luarocks install preview.nvim

Quick Start

Enable exactly the providers you need before preview.nvim loads.

vim.g.preview = { typst = true }

Open a Typst document and start the watch preview from that buffer.

:Preview

When you only need a single build, run the compile subcommand instead of starting the watcher.

:Preview compile

If a compile fails, inspect the raw compiler log after checking diagnostics or quickfix.

:Preview output

After a successful build, reopen the last artifact without recompiling.

:Preview open

Documentation

:help preview

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,
    failure_summary = function(result)
      return result.output:match('^ERROR:%s*(.+)$')
    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: Markdown compilation drops .html files in my working directory. How do I send output to /tmp instead?

Override the output field. The args function references ctx.output, so the compiled file lands wherever output points:

vim.g.preview = {
  github = {
    output = function(ctx)
      return '/tmp/' .. vim.fn.fnamemodify(ctx.file, ':t:r') .. '.html'
    end,
  },
}

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

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

Q: How do I inspect the full compiler output?

If a compile fails, check diagnostics or quickfix first when available. For the raw compiler output, use:

:Preview output

Compilation failures intentionally use a short notification. Providers can optionally define failure_summary(result, ctx) to customize that message. The full raw compiler output is available through :Preview output and require('preview').result(). One-shot providers replace the stored output on each compile. Long-running providers such as typst watch show the current watch-session log.