Giter Club home page Giter Club logo

github-preview.nvim's Introduction

Markdown Live Preview for Neovim

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

Powered by Bunvim and Pantsdown.

demo.mp4

โœจ Features

โœ… Requirements

๐Ÿ“ฆ Installation

Using lazy.nvim

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

        local fns = gpreview.fns
        vim.keymap.set("n", "<leader>mpt", fns.toggle)
        vim.keymap.set("n", "<leader>mps", fns.single_file_toggle)
        vim.keymap.set("n", "<leader>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.

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 <details> tags on init/content-change
    -- true: <details> tags are rendered open
    -- false: <details> 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

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 <details> 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

github-preview.nvim's People

Contributors

dependabot[bot] avatar scottmckendry avatar wallpants avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

github-preview.nvim's Issues

reuse explorer code

reuse more explorer code in both the sidebar explorer and the markdown container explorer

readme installation

update packer.nvim installation instructions to look more similar to lazy.nvim

also do we need to specify disable=false?

toast system

develop a toast system to render on websocket message

use one of those toasts to tell the user relative links are disabled

config gif

create gif showcasing temporary config overrides

back navigation

think of a way to make the browser's back button usable

maybe give users the option to disable auto-close in favour of back-navigation.

allow users to specify autoclose true or false, but add a warning in the docs saying that enabling autoclose disables
the back button.

hash scrolling

rethink hash scrolling both for code line ranges and headings

[Bug]: Out of memory

What happened?

After installing the plugin, try opening github-preview with GithubPreviewToggle.
I got the notification saying github-preview: init.

After 10s, the terminal crash saying it's using too much memory.

I guess the plugin load all the files into memory to display on browser.

What browsers are you seeing the problem on?

Firefox

:checkhealth

github-preview: require("github-preview.health").check()

github-preview.nvim ~
- platform: linux
- git-commit: a4c7dd98eb274834bfe15629b540fe13ead83b06
- OK bun: 1.0.7

single file

enabling single file when looking at a dir breaks stuff

lighter docs gifs

some of them are a bit too heavy and on slow internet they take a bit to load

better mermaid support

  • #112
  • replace mermaid example in features.md with something more legible
  • center svgs
  • import mermaid in a script tag in head, add mermaid version from devDependecy as BUILD_CONST to get matching version in script tag.
  • #113

clear autocommands on unalive http

if I start github-preview in an instance of neovim, and then start github-preview in another instance of neovim,
the first instance of neovim breaks and we start getting a ton of errors saying that the rpc channel id is not valid

fix checkhealth

I don't know what that is that we're printing but I couldn't find anything related to the commit the guy pasted in the bug report lol.

#171

also make it return something less generic than "linux"

memoize mermaid svgs

(this might fix the scroll jumping when mermaid diagrams above cursor line & improve performance)

export builtin functions

export builtin functions like telescope does and add docs explaining how to use them to setup a user-command or a keymap

in an Advanced Usage section of the readme

absolute links new tab

open absolute links in a new tab to prevent clicking on them from disabling autoclose.

Autoclose can only work if the navigation stack is emtpy. This is why we use "replace" instead of "push" when navigating.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.