๐ฆ markdown-live-preview
A Rust-powered live Markdown preview server that integrates with Neovim via TCP.
Renders GitHub-flavored Markdown (GFM) using Comrak, served via Axum, and controlled in real time from an md-live-preview.nvim plugin.
[!NOTE] This project is designed to be paired with a Neovim plugin that streams buffer changes and cursor position.
๐ฆ Features
| Feature | Status | Notes |
|---|---|---|
| Live buffer preview | โ | Renders latest Markdown buffer to HTML |
| Cursor tracking | โ | Receives cursor position updates |
| Incremental updates | โ | Only sends changed lines |
| GFM rendering | โ | Uses comrak with alerts, tables, etc. |
| Local TCP interface | โ | Neovim pushes updates to 127.0.0.1:3001 |
| HTML server | โ | Axum serves preview on http://localhost:3000 |
| Auto-launch browser | โ | Opens system browser on start |
| WebSocket live reload | ๐ง | Planned |
๐ Getting Started
๐ง Prerequisites
- Rust (1.70+ recommended)
- Neovim 0.9+
md-live-preview.nviminstalled and configured
๐ Build and run
๐ Communication Protocol
The server listens on 127.0.0.1:3001 for newline-delimited JSON messages.
โ๏ธ Incoming message format
Supported event types:
| Event | Payload Structure |
|---|---|
| init | { content: Vec, cursor: (usize, usize) } |
| buffer_change | { line: usize, new_text: String } |
| cursor_moved | { cursor: (usize, usize) } |
[!TIP] Lines are indexed from zero.
๐ Web Interface
- URL: http://localhost:3000
- Automatically opens in the default browser on launch
- Reflects live updates from Neovim
๐ Architecture
[ Neovim (plugin) ] --> TCP (127.0.0.1:3001) --> [ markdown-live-preview ]
--> Axum --> HTML preview (localhost:3000)
๐งช Debugging
You can log incoming messages using:
RUST_LOG=debug
[!WARNING] Always restart the server if you change port bindings or encounter connection issues.
๐ License
MIT ยฉ Shane Poppleton