Universal document previewer for Neovim
An extensible framework for compiling and previewing any documents (LaTeX, Typst, Markdown, etc.)—diagnostics included.
vim.system()vim.diagnosticPreviewCompileStarted,
PreviewCompileSuccess,
PreviewCompileFailed)Install with your package manager of choice or via luarocks:
luarocks install preview.nvim
:help preview.nvim
Q: How do I define a custom provider?
require('preview').setup({
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?
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 in toggle/watch mode. For a
specific application, pass a command table:
require('preview').setup({
typst = { open = { 'sioyek', '--new-instance' } },
})