A Neovim plugin for easily previewing PDF documents in your browser, with automatic reloading on file changes. This plugin is ideal for a minimalist LaTeX editing workflow, even on a remote server or in a dev container.
- 🔄 Auto-reloading: Refreshes the browser when your PDF file changes.
- 🔌 Remote-friendly: Works over SSH with port forwarding.
- 🪞 Transparent: No side effects in your project.
- ⚙️ Minimal config: Simple
setup()with sensible defaults.
- Node.js (for
npmandnpx)
Using lazy.nvim :
{
"franco-ruggeri/pdf-preview.nvim",
opts = {
-- Override defaults here
}
config = function(_, opts)
require("pdf-preview").setup(opts)
-- Add your keymaps here
end
}The following user commands are created:
:PdfPreviewStart: Start PDF preview.:PdfPreviewStop: Stop PDF preview.:PdfPreviewToggle: Toggle PDF preview.
After using :PdfPreviewStart, open the printed URL (e.g.,
http://localhost:3000) in your browser.
The default configuration is as follows:
{
-- Port where the browser-sync server will try to listen on.
-- If nil, the default browser-sync behavior will be followed.
port = nil,
-- Debounce delay for refresh events in milliseconds
reload_debouce = 500,
}This plugin works nicely with LaTeX. Just compile the LaTeX project into a PDF document.
For instance, you can:
-
Install the
texlabLSP server usingmason.nvim. -
Configure
texlabto compile on save.vim.lsp.config("texlab", { settings = { texlab = { build = { onSave = true, }, }, }, })
The texlab LSP server will take care of compiling on save, and pdf-preview
will watch for changes in the output PDF document.
You can use SSH port forwarding to view the PDF remotely:
ssh -L <local-port>:localhost:<remote-port> <remote-user>@<remote-host>You can use port forwarding by setting the forwardPorts property. See the
official documentation.
All contributions are welcome! Open an issue to discuss ideas and open a pull request once agreed.
