Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wallpants/github-preview.nvim

Live Preview of your Markdown (GFM) files & local git repositories for Neovim.
https://github.com/wallpants/github-preview.nvim

bunvim gfm github live markdown neovim nvim preview

Last synced: 18 days ago
JSON representation

Live Preview of your Markdown (GFM) files & local git repositories for Neovim.

Awesome Lists containing this project

README

        

# Markdown Live Preview for Neovim

[](https://neovim.io/)
[](https://github.com/)
[](https://bun.sh/)

Live Preview of your GitHub Flavored Markdown files & local git repositories.

Powered by [Bunvim](https://github.com/wallpants/bunvim) and [Pantsdown](https://github.com/wallpants/pantsdown).

https://github.com/wallpants/github-preview.nvim/assets/47203170/e332a671-0ee4-4f8c-929e-d2c5c5d6f273

## ✨ Features

* [💻 Linux / macOS / WSL](/docs/FEATURES.md#-linux--macos--wsl)
* [🔴 LIVE updates](/docs/FEATURES.md#-live-updates)
* [♻️ Synced Scrolling](/docs/FEATURES.md#%EF%B8%8F-synced-scrolling)
* [🌈 Dark & Light modes](/docs/FEATURES.md#-dark--light-modes)
* [🖍️ Cursorline in Preview](/docs/FEATURES.md#%EF%B8%8F-cursorline-in-preview)
* [📹 Video Support](/docs/FEATURES.md#-video-support)
* [🏞️ Local Image Support](/docs/FEATURES.md#%EF%B8%8F-local-image-support)
* [🧜 Mermaid Support](/docs/FEATURES.md#-mermaid-support)
* [📌 Single-file mode](/docs/FEATURES.md#-single-file-mode)
* [📂 Repository mode](/docs/FEATURES.md#-repository-mode)

## ✅ Requirements

* [x] [Bun](https://bun.sh)
* [x] [Neovim](https://neovim.io)

## 📦 Installation

Using lazy.nvim

```lua
{
"wallpants/github-preview.nvim",
cmd = { "GithubPreviewToggle" },
keys = { "mpt" },
opts = {
-- config goes here
},
config = function(_, opts)
local gpreview = require("github-preview")
gpreview.setup(opts)

local fns = gpreview.fns
vim.keymap.set("n", "mpt", fns.toggle)
vim.keymap.set("n", "mps", fns.single_file_toggle)
vim.keymap.set("n", "mpd", fns.details_tags_toggle)
end,
}
```

## ⚙️ Configuration

I recommend you start off with the default settings and play around with the UI to figure out
what settings you want to override before committing to updating your config files.

All values are optional, you can leave empty to use default values.
Any values you specify will be deeply merged with this dictionary.

```lua
require("github-preview").setup({
host = "localhost",

-- port used by local server
port = 6041,

-- set to "true" to force single-file mode & disable repository mode
single_file = false,

theme = {
-- "system" | "light" | "dark"
name = "system",
high_contrast = false,
},

-- define how to render tags on init/content-change
-- true: tags are rendered open
-- false: tags are rendered closed
details_tags_open = true,

cursor_line = {
disable = false,

-- CSS color
-- if you provide an invalid value, cursorline will be invisible
color = "#c86414",
opacity = 0.2,
},

scroll = {
disable = false,

-- Between 0 and 100
-- VERY LOW and VERY HIGH numbers might result in cursorline out of screen
top_offset_pct = 35,
},

-- for debugging
-- nil | "debug" | "verbose"
log_level = nil,
})
```

## 💻 Usage

🚨 The first time the plugin runs, it might take a few seconds for your browser to open as dependencies are being downloaded.
This might happen again after a plugin update if there were any changes to the plugin dependencies.

### `:GithubPreviewToggle`

**Starts** the plugin if not running or **stops** it if it's already running.

### `:GithubPreviewStart`

**Start** plugin. Any previously created instances are killed.

### `:GithubPreviewStop`

**Stops** the plugin. Closes browser tab as well.

## 🧠 Advanced Usage

This plugin also exports **functions** for you to
[set keymaps](),
trigger stuff in [autocommands](),
[create user commands](), etc.

### Available functions

```lua
local gpreview = require("github-preview")
local fns = gpreview.fns

gpreview.setup({ ... })

-- plugin start/stop
fns.toggle()
fns.start()
fns.stop()

-- clear current session's config overrides
-- and fallback to your config files
fns.clear_overrides()

-- single-file mode enable/disable
fns.single_file_toggle()
fns.single_file_on()
fns.single_file_off()

-- render tags open/closed
fns.details_tags_toggle()
fns.details_tags_open()
fns.details_tags_closed()

-- synced scroll enable/disable
fns.scroll_toggle()
fns.scroll_on()
fns.scroll_off()

-- cursorline enable/disable
fns.cursorline_toggle()
fns.cursorline_on()
fns.cursorline_off()
```

## 👷 Development & Contributing

[See documentation](/docs/CONTRIBUTING.md)