Skip to content

dpi0/moo.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

moo.nvim

Shows a live markdown preview of the current buffer's .md file using the cli tool gh-markdown-preview

Notification inside Neovim Preview in Firefox

Note

Built with Claude Sonnet 4.5 Free Plan.

Requirements

Neovim 0.8.0+

gh-markdown-preview 1.8.0+

Installation

{
  'dpi0/moo.nvim',
}

To install gh-markdown-preview using the GitHub gh cli, refer

gh extension install yusukebe/gh-markdown-preview

Warning

gh markdown-preview works only when online as it uses the GitHub API for preview. Use the hard fork gfm for offline only usage.

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()

Configuration

Options

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")
}

Keybinds

keys = {
  {
    '<leader>mkp',
    function()
      require('moo').preview()
    end,
    desc = '[M]ar[k]down [P]review',
    mode = 'n',
  },

  -- And more
}

Example Configuration for lazy.nvim

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',
    },
  },
}

About

Shows a live markdown preview in browser using yusukebe/gh-markdown-preview

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages