Skip to content

franco-ruggeri/pdf-preview.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF Preview 🧾🔍

📚 Overview

A Neovim plugin for easily previewing PDF documents in your browser, with automatic reloading on file changes. This plugin is ideal for a minimalist LaTeX editing workflow, even on a remote server or in a dev container.

demo

✨ Features

  • 🔄 Auto-reloading: Refreshes the browser when your PDF file changes.
  • 🔌 Remote-friendly: Works over SSH with port forwarding.
  • 🪞 Transparent: No side effects in your project.
  • ⚙️ Minimal config: Simple setup() with sensible defaults.

⚡ Requirements

  • Node.js (for npm and npx)

📦 Installation

Using lazy.nvim :

{ 
    "franco-ruggeri/pdf-preview.nvim", 
    opts = {
        -- Override defaults here
    }
    config = function(_, opts)
        require("pdf-preview").setup(opts)

        -- Add your keymaps here
    end
}

🚀 Usage

The following user commands are created:

  • :PdfPreviewStart : Start PDF preview.
  • :PdfPreviewStop : Stop PDF preview.
  • :PdfPreviewToggle : Toggle PDF preview.

After using :PdfPreviewStart, open the printed URL (e.g., http://localhost:3000) in your browser.

🛠️ Configuration

The default configuration is as follows:

{
    -- Port where the browser-sync server will try to listen on. 
    -- If nil, the default browser-sync behavior will be followed.
    port = nil,
    -- Debounce delay for refresh events in milliseconds
    reload_debouce = 500,
}

💡 Workflow Tips

🧪 LaTeX

This plugin works nicely with LaTeX. Just compile the LaTeX project into a PDF document.

For instance, you can:

  • Install the texlab LSP server using mason.nvim.

  • Configure texlab to compile on save.

    vim.lsp.config("texlab", {
      settings = {
          texlab = {
              build = {
                  onSave = true,
              },
          },
      },
    })

The texlab LSP server will take care of compiling on save, and pdf-preview will watch for changes in the output PDF document.

🌐 Remote server

You can use SSH port forwarding to view the PDF remotely:

ssh -L <local-port>:localhost:<remote-port> <remote-user>@<remote-host>

🐳 Dev container

You can use port forwarding by setting the forwardPorts property. See the official documentation.

🤝 Contributing

All contributions are welcome! Open an issue to discuss ideas and open a pull request once agreed.

About

Neovim plugin for live PDF preview - LaTeX workflow in containers

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages