Give your Neovim buffers real previews instead of raw file bytes.
buffer-preview.nvim hijacks the normal buffer read for supported
files and replaces raw bytes with a read-only, navigable in-buffer preview.
Keep the document inside Neovim, move with familiar Vim keys, and avoid
context-switching to a separate viewer.
- Neovim >= 0.10
- image.nvim (handles image rendering)
- ImageMagick (required by image.nvim)
pdftoppmorpdftocairo(frompoppler/poppler-utils)pdfinfo(frompoppler/poppler-utils)
sofficefor presentation preview conversion (.pptx,.ppt,.odp)
~/.tmux.conf
# https://github.com/3rd/image.nvim#tmux
set -gq allow-passthrough on
set -g visual-activity off
set -g focus-events onWith lazy.nvim:
{
"propilideno/buffer-preview.nvim",
event = { "BufReadCmd *.pdf", "BufReadCmd *.pptx", "BufReadCmd *.ppt", "BufReadCmd *.odp" }, -- fires before Neovim reads the file, earlier than ft
dependencies = { "3rd/image.nvim" },
opts = {},
}sudo pacman -S poppler imagemagick \
libreoffice-fresh # Optional: for presentation previewsudo apt install poppler-utils imagemagick \
libreoffice # Optional: for presentation previewAll fields are optional. These currently configure the PDF rendering backend.
require("buffer-preview").setup({
-- "pdftoppm" (default) or "pdftocairo"
rasterizer = "pdftoppm",
-- Rasterization DPI (higher = sharper but slower)
dpi = 200,
-- Where rendered page PNGs are cached
cache_dir = vim.fn.stdpath("cache") .. "/buffer-preview.nvim",
})- buffer-hijacking: supported buffers are hijacked and rendered as previews instead of raw bytes
- page-viewer: read-only buffer with Vim-style page movement
- PDF support (.pdf)
- PowerPoint support (.pptx, .ppt)
- OpenDocument Presentation support (.odp)
- SQLite support
- Parquet support
- Excel support
| Key | Action |
|---|---|
j l ↓ ] } Space Ctrl-d Ctrl-f |
Next page |
k h ↑ [ { Ctrl-u Ctrl-b |
Previous page |
g |
First page |
G |
Last page |
<number>G |
Go to page N |
r Ctrl-l |
Refresh |
q |
Close viewer |
BufReadCmdhijacks supported files before Neovim reads their raw bytes.- The plugin replaces the file buffer with a read-only scratch buffer.
- A format-specific backend generates preview data for that buffer.
- The preview is rendered in-place while normal Neovim navigation remains in control.
For PDFs, the backend:
- Detects page count with
pdfinfo - Rasterizes pages to PNG with
pdftoppmorpdftocairo - Displays the page with
image.nvim - Uses page-navigation mappings instead of normal text editing
For presentation files (.pptx, .ppt, .odp), the backend:
- Converts the presentation to PDF with
soffice --headless - Reuses the same PDF page-count, rasterization, and display pipeline
- Keeps the same in-buffer navigation and
Pagelayout
plugin/buffer-preview.lua: registers buffer hijacking for supported formatslua/buffer-preview/converter.lua: converts presentation files to cached PDF withsofficelua/buffer-preview/viewer.lua: PDF preview buffer lifecyclelua/buffer-preview/rasterizer.lua: PDF page rasterization and cachelua/buffer-preview/display.lua: image rendering viaimage.nvimlua/buffer-preview/config.lua: backend configuration

