High-fidelity DOCX previews inside Neovim. nvim-office renders documents with
docx-renderer, captures each Word
page in headless Chrome, and displays it through the Kitty graphics protocol.
- Neovim 0.10 or newer
- Node.js 20 or newer
- Google Chrome or Chromium
- snacks.nvim with image support enabled
- kitty, Ghostty, or WezTerm
Zellij cannot pass the required graphics protocol through to Neovim.
With lazy.nvim:
{
"Stasshe/nvim-office",
dependencies = { "folke/snacks.nvim" },
build = "npm install --omit=dev",
opts = {},
}Enable the Snacks image module:
{
"folke/snacks.nvim",
opts = {
image = {},
},
}Open a document normally:
nvim document.docxThe first page appears as soon as it is captured while the remaining pages render in the background. Reopening an unchanged document reuses its cached preview. The preview is read-only. Default mappings:
| Key | Action |
|---|---|
j |
Next page |
k |
Previous page |
gg |
First page |
G |
Last page |
r |
Render again, ignoring the cache |
q |
Close preview |
Commands :NvimOfficeNext, :NvimOfficePrevious, and
:NvimOfficeRefresh provide the same operations.
require("nvim-office").setup({
browser = "/path/to/chrome",
node = "node",
render_timeout = 30000,
keymaps = {
next = "j",
previous = "k",
first = "gg",
last = "G",
refresh = "r",
close = "q",
},
})browser is optional when Chrome or Chromium is on PATH. Set CHROME_PATH
to configure it without Lua. A key can be disabled by assigning false.
pnpm install
pnpm check
pnpm buildRender a file without Neovim:
pnpm render document.docx /tmp/nvim-office-previewMIT