Real-time Markdown preview for Neovim with GitHub Flavored Markdown styling.
- Live preview updates as you type (no save required)
- GitHub Flavored Markdown rendering
- Light/dark theme toggle
- Syntax highlighting for code blocks
- KaTeX math support
- Mermaid diagram support
- Self-contained HTML export
- Headless mode support
- Neovim 0.9+
- curl (for downloading pre-compiled binaries)
- Rust toolchain (only if building from source)
Pre-compiled binaries are automatically downloaded for Linux and macOS (x86_64 and aarch64):
{
"vihu/penview.nvim",
build = function()
require("penview.build").install()
end,
ft = "markdown",
config = function()
require("penview").setup({
browser = "firefox", -- Required: your browser command
-- debounce = 100, -- Optional: ms to wait before updating (default: 100)
-- port = 0, -- Optional: server port (default: random)
-- debug = false, -- Optional: enable debug logging
-- sync_scroll = true, -- Optional: sync scroll with nvim (default: true)
})
end,
keys = {
{ "<leader>po", "<cmd>PenviewStart<cr>", desc = "[P]review [O]pen" },
{ "<leader>pc", "<cmd>PenviewStop<cr>", desc = "[P]review [C]lose" },
},
}use {
"vihu/penview.nvim",
run = function()
require("penview.build").install()
end,
config = function()
require("penview").setup({
browser = "firefox",
})
end,
}Plug 'vihu/penview.nvim', { 'do': ':lua require("penview.build").install()' }
" In your init.vim or after/plugin:
lua require("penview").setup({ browser = "firefox" })If pre-compiled binaries are unavailable for your platform, or you prefer to build from source:
-- lazy.nvim
{
"vihu/penview.nvim",
build = "make build", -- Requires Rust toolchain
-- ...
}Build dependencies:
- Rust toolchain (stable)
- libluajit (libluajit-5.1-dev on Debian/Ubuntu)
- libclang-dev
- pkg-config
- Open a markdown file
- Run
:PenviewStartor press<leader>po - Browser opens with live preview
- Edit your markdown - preview updates in real-time
- Run
:PenviewStopor press<leader>pcto stop
For neovim running on Linux servers without a browser, use headless mode to expose the HTTP server for remote access.
On the remote server, configure penview with headless mode:
require("penview").setup({
headless = true, -- Enable headless mode (binds to 0.0.0.0), required.
port = 9876, -- Port for remote access, required.
})- Remote server: Open a markdown file and run
:PenviewStart - Local machine: Create an SSH tunnel to the remote server:
ssh -L 9876:localhost:9876 remote-server
- Local browser: Open the preview URL:
(use the absolute path to the file on the remote server)
http://localhost:9876?path=/path/to/file.md
The preview updates in real-time as you edit the file on the remote server.
| Command | Description |
|---|---|
:PenviewStart |
Start the preview server and open browser |
:PenviewStop |
Stop the preview server |
This plugin basically is a combination of the following original works:
- tatum: Original Markdown renderer
- websocket.nvim: WebSocket client for Neovim
MIT