Skip to content

Stasshe/nvim-office

Repository files navigation

nvim-office

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.

Requirements

  • 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.

Installation

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 = {},
  },
}

Usage

Open a document normally:

nvim document.docx

The 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.

Configuration

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.

Development

pnpm install
pnpm check
pnpm build

Render a file without Neovim:

pnpm render document.docx /tmp/nvim-office-preview

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages