Shows a live markdown preview of the current buffer's .md file using the cli tool gh-markdown-preview
Note
Built with Claude Sonnet 4.5 Free Plan.
Neovim 0.8.0+
gh-markdown-preview 1.8.0+
{
'dpi0/moo.nvim',
}To install gh-markdown-preview using the GitHub gh cli, refer
gh extension install yusukebe/gh-markdown-previewWarning
gh markdown-preview works only when online as it uses the GitHub API for preview. Use the hard fork gfm for offline only usage.
Call the preview function to launch a preview for the current buffer in your default browser:
:lua require("moo").preview()To list all previews for the current Neovim instance:
:lua require("moo").list_previews()To kill preview for the current buffer:
:lua require("moo").kill_preview()To kill all previews for the current Neovim instance:
:lua require("moo").kill_all_previews()These are implemented in reference to gh markdown-preview --help
opts = {
dark_mode = false, -- Force dark mode (Default: false)
light_mode = false, -- Force light mode (Default: false)
disable_auto_open = false, -- Don't auto-open browser (Default: false)
disable_reload = false, -- Disable live reloading (Default: false)
host = 'localhost', -- Hostname this server will bind (Default: 'localhost')
port = 3333, -- TCP port number of this server (Default: 3333)
markdown_mode = false, -- Force "markdown" mode (Rather than the Default: "gfm")
}keys = {
{
'<leader>mkp',
function()
require('moo').preview()
end,
desc = '[M]ar[k]down [P]review',
mode = 'n',
},
-- And more
}return {
'dpi0/moo.nvim',
ft = 'markdown', -- Only load the plugin for `.md` files
opts = {
markdown_mode = true, -- Force "markdown" mode (Default: false)
},
keys = {
{
'<leader>mkp',
function()
require('moo').preview()
end,
desc = '[M]ar[k]down [P]review',
mode = 'n',
},
{
'<leader>mkl',
function()
require('moo').list_previews()
end,
desc = '[M]ar[k]down [L]ist Previews',
mode = 'n',
},
{
'<leader>mkk',
function()
require('moo').kill_preview()
end,
desc = '[M]ar[k]down [K]ill Current Buffer Preview',
mode = 'n',
},
{
'<leader>mkK',
function()
require('moo').kill_all_previews()
end,
desc = '[M]ar[k]down [K]ill All Previews',
mode = 'n',
},
},
}