Skip to content

A simple Neovim plugin for previewing Markdown files in a floating window or your browser, with live updates and scroll synchronization

License

Notifications You must be signed in to change notification settings

andev0x/mdview.nvim

mdview.nvim


lint license issues stars

A simple Neovim plugin for previewing Markdown files in a floating window or your browser, with live updates and scroll synchronization.

Features

  • Live preview of Markdown files.
  • Scroll synchronization between Neovim and the browser.
  • Floating window preview inside Neovim using w3m.
  • Open the preview in your default browser.
  • Dark mode support (toggled with the t key).
  • Yank the rendered HTML to the clipboard.

Demo

"

Dependencies

  • node
  • pandoc
  • w3m (for the floating window preview)
  • curl

Installation

Using packer.nvim:

use {
  'andev0x/mdview.nvim',
  run = 'npm install',
}

Using lazy.nvim:

{
  'andev0x/mdview.nvim',
  build = 'npm install',
  config = function()
    require('mdview').setup()
  end,
}

Usage

  • :MDView - Start the preview for the current Markdown file.
  • :MDStop - Stop the preview.

The preview will open in a floating window. You can also open it in your browser by pressing o in the preview window.

Keymaps (in the preview window)

  • q - Close the preview window.
  • o - Open the preview in your default browser.
  • t - Toggle between light and dark themes.
  • y - Yank the rendered HTML to the system clipboard.

Configuration

You can configure the plugin by passing a setup function to the setup method.

require('mdview').setup({
  -- The port to use for the web server.
  port = 8080,
  -- The host to use for the web server.
  host = '127.0.0.1',
  -- The template to use for the HTML output.
  -- You can use the following placeholders:
  --   - `{{title}}` - The title of the document.
  --   - `{{body}}` - The body of the document.
  --   - `{{theme}}` - The theme of the document (light or dark).
  --   - `{{ws_address}}` - The address of the WebSocket server.
  template = '<html>...</html>',
  -- The dark theme template.
  template_dark = '<html>...</html>',
  -- The command to use for opening the browser.
  browser_cmd = 'xdg-open',
  -- The command to use for yanking the HTML to the clipboard.
  yank_cmd = 'xclip -selection clipboard',
})

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

About

A simple Neovim plugin for previewing Markdown files in a floating window or your browser, with live updates and scroll synchronization

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published