preview.nvim/README.md
Barrett Ruth 0b16ff7178
Refactor/preset name true syntax (#4)
* refactor(config): replace array preset syntax with preset_name = true

Problem: setup() mixed array entries (preset names) and hash entries
(custom providers keyed by filetype), requiring verbose
vim.tbl_deep_extend boilerplate to override presets.

Solution: unify under a single key=value model. Keys are preset names
or filetypes; true registers the preset as-is, a table deep-merges
with the matching preset (or registers a custom provider if no preset
matches), and false is a no-op. Array entries are dropped. Also adds
-f gfm to presets.github args so pandoc parses input as GFM.

* ci: format

* fix(presets): parenthesize gsub output to suppress redundant-return-value

* ci: remove superfluous things

* refactor: remove PreviewWatch* events and clean up docs

Problem: PreviewWatchStarted/PreviewWatchStopped were redundant with
the status() API, and the doc had a wrong author, stale INSTALLATION
format, and "watch mode" language left over from the watch → toggle
rename.

Solution: Remove the events and their tests. Fix the doc author,
rename INSTALLATION → SETUP to match sibling plugins, replace "watch
mode" with "auto-compile" throughout, and drop the events from EVENTS.
2026-03-03 00:49:10 -05:00

73 lines
1.5 KiB
Markdown

# preview.nvim
**Async document compilation for Neovim**
An extensible framework for compiling documents (LaTeX, Typst, Markdown, etc.)
asynchronously with error diagnostics.
## Features
- Async compilation via `vim.system()`
- Compiler errors as native `vim.diagnostic`
- User events for extensibility (`PreviewCompileStarted`,
`PreviewCompileSuccess`, `PreviewCompileFailed`)
- Built-in presets for Typst, LaTeX, Markdown, and GitHub-flavored Markdown
- `:checkhealth` integration
- Zero dependencies beyond Neovim 0.11.0+
## Requirements
- Neovim 0.11.0+
## Installation
Install with your package manager of choice or via
[luarocks](https://luarocks.org/modules/barrettruth/preview.nvim):
```
luarocks install preview.nvim
```
## Documentation
```vim
:help preview.nvim
```
## FAQ
**Q: How do I define a custom provider?**
```lua
require('preview').setup({
typst = {
cmd = { 'typst', 'compile' },
args = function(ctx)
return { ctx.file }
end,
output = function(ctx)
return ctx.file:gsub('%.typ$', '.pdf')
end,
},
})
```
**Q: How do I override a preset?**
```lua
require('preview').setup({
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. For
a specific application, pass a command table:
```lua
require('preview').setup({
typst = { open = { 'sioyek', '--new-instance' } },
})
```