Skip to content

xunoaib/pdf-snippet.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βœ‚οΈ pdf-snippet.nvim

pdf-snippet.nvim is a Neovim plugin that lets you grab pages from PDFs and drop them straight into your notes as images -- complete with an annotation and Markdown link back to the source.

It's perfect for lecture notes, research annotations, or any workflow where you want quick, visual snippets from your PDFs without breaking your writing flow.

✨ Features

  • Select a PDF with Telescope
  • Enter a page number (with optional label)
  • Converts the page to an image via a bundled Python script
  • Inserts a Markdown image link at your cursor
  • Each image is named and annotated with the source PDF and page number

🐍 Requirements

  • Python >= 3.10

  • Libraries:

    pip install -r python/requirements.txt

    (or manually: pip install pdf2image pillow)

  • System Dependency: Poppler (provides pdftopp/pdftocairo)

    • Ubuntu: sudo apt install poppler-utils
    • Arch: sudo pacman -S poppler
    • macOS: brew install poppler
    • Windows: download Poppler binaries and add them to your PATH

πŸ“¦ Installation

Using lazy.nvim:

{
  "xunoaib/pdf-snippet.nvim",
  dependencies = { "nvim-telescope/telescope.nvim" },
  config = function()
    -- Small helper for defining project directories
    local function project(base)
      return {
        root   = base,                   -- Project root
        pdfs   = base .. "/pdfs",        -- PDF input directory
        outdir = base .. "/extractions", -- PNG output directory
      }
    end

    require("pdf_snippet").setup({
      enable_default_keymaps = true,
      projects = {
        -- Add as many projects as you want
        course1 = project("~/edu/course1"),
        course2 = project("~/edu/course2"),
      },
    })
  end,
}

πŸš€ Usage

  • Run manually with:

    :InsertPdfSnippet
    
  • If enable_default_keymaps = true, use:

    <leader>ps
    
  • Or define your own mapping:

    vim.keymap.set("n", "<leader>ps", "<cmd>InsertPdfSnippet<cr>", { desc = "Insert PDF Snippet" })

βš™οΈ Customization

The conversion logic lives in python/extract.py.

Edit this file to change options like the Markdown link format, DPI, scale factor, fonts, or annotation style.

About

Clip pages from your PDFs into Markdown directly from Neovim.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published