No description
Problem: in toggle mode, each BufWritePost immediately spawned a new compilation, killing any in-flight process. Rapid saves wasted cycles on compilers like latexmk. Solution: add a 500ms debounce timer per buffer. The BufWritePost callback starts/restarts the timer instead of compiling immediately. Timers are cleaned up on unwatch and BufWipeout. |
||
|---|---|---|
| .github/workflows | ||
| doc | ||
| lua/preview | ||
| plugin | ||
| spec | ||
| .busted | ||
| .editorconfig | ||
| .gitignore | ||
| .luarc.json | ||
| .prettierrc | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| preview.nvim-scm-1.rockspec | ||
| README.md | ||
| selene.toml | ||
| stylua.toml | ||
| vim.yaml | ||
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
:checkhealthintegration- Zero dependencies beyond Neovim 0.11.0+
Requirements
- Neovim 0.11.0+
Installation
Install with your package manager of choice or via luarocks:
luarocks install preview.nvim
Documentation
:help preview.nvim
FAQ
Q: How do I define a custom provider?
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?
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:
require('preview').setup({
typst = { open = { 'sioyek', '--new-instance' } },
})