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.
The requirements depends on which preview you want, install only what you need.
For PDF and presentation files (.pdf, .pptx, .ppt, .odp):
- image.nvim: handles image rendering
- ImageMagick: required by image.nvim
- pdftoppm: required to convert pdf to png
- pdfinfo: required to show metadata (status line)
- soffice: for presentation conversion (.pptx, .ppt, .odp)
For running image preview inside tmux, add to ~/.tmux.conf:
# https://github.com/3rd/image.nvim#tmux
set -gq allow-passthrough on
set -g visual-activity off
set -g focus-events on- sqlite3: for SQLite files (.db, .sqlite, .sqlite3)
With lazy.nvim:
{
"propilideno/buffer-preview.nvim",
event = {
-- Image preview
"BufReadCmd *.pdf", "BufReadCmd *.pptx", "BufReadCmd *.ppt", "BufReadCmd *.odp",
-- Data preview
"BufReadCmd *.db", "BufReadCmd *.sqlite", "BufReadCmd *.sqlite3",
},
dependencies = {
"3rd/image.nvim", -- only needed for image preview (PDF / presentation)
},
opts = {},
}# Image preview dependencies
sudo pacman -S poppler imagemagick \
libreoffice-fresh # Optional: for presentation preview
# Data preview dependencies
sudo pacman -S sqlite# Image preview dependencies
sudo apt install poppler-utils imagemagick \
libreoffice # Optional: for presentation preview
# Data preview dependencies
sudo apt install sqlite3All 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 (.db, .sqlite, .sqlite3)
- 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 |
Opening a .db / .sqlite / .sqlite3 file spawns a two-buffer workspace:
- Top — read-only result preview. Initially shows the database schema (tables, views, triggers).
- Bottom — editable SQL buffer. Write any SQL that
sqlite3accepts, including writes and DDL.
| Key / Command | Action |
|---|---|
:w (save the buffer):BufferPreviewRunQuery |
Run the whole bottom buffer as SQL |
The bottom buffer's contents are preserved after a run. Successful write
statements render Query executed successfully in the top buffer; errors
render -- Error followed by the sqlite3 stderr.
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
For SQLite files (.db, .sqlite, .sqlite3), the backend:
- Opens a two-buffer workspace: a read-only result buffer on top and an editable SQL buffer on the bottom
- Runs an initial schema query against
sqlite_masterto orient the user - Pipes the bottom buffer's contents into the
sqlite3CLI via stdin and renders the result (table / success message / error) into the top buffer
plugin/buffer-preview.lua: dispatches buffer hijacking per backendlua/buffer-preview/image/viewer.lua: PDF / presentation preview buffer lifecyclelua/buffer-preview/image/converter.lua: converts presentation files to cached PDF withsofficelua/buffer-preview/image/rasterizer.lua: PDF page rasterization and cachelua/buffer-preview/image/display.lua: image rendering viaimage.nvimlua/buffer-preview/data/runner.lua:sqlite3CLI wrapper (data backends)lua/buffer-preview/data/viewer.lua: two-buffer data workspacelua/buffer-preview/config.lua: backend configuration