GithubHelp home page GithubHelp logo

liamsnow / peek.nvim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from toppair/peek.nvim

0.0 0.0 0.0 159 KB

Markdown preview plugin for Neovim - Forked with some extra MarkdownIt Extensions

License: MIT License

JavaScript 7.76% Lua 19.25% TypeScript 62.87% CSS 8.61% HTML 1.52%

peek.nvim's Introduction

peek.nvim

Markdown preview plugin for Neovim

preview

โœจ Features

  • live update
  • synchronized scrolling
  • github-style look
  • TeX math
  • Mermaid diagrams

๐Ÿ”‹ Requirements

๐Ÿ”Œ Installation

lazy.nvim
{
    "toppair/peek.nvim",
    event = { "VeryLazy" },
    build = "deno task --quiet build:fast",
    config = function()
        require("peek").setup()
        vim.api.nvim_create_user_command("PeekOpen", require("peek").open, {})
        vim.api.nvim_create_user_command("PeekClose", require("peek").close, {})
    end,
},

๐Ÿ”ง Configuration

-- default config:
require('peek').setup({
  auto_load = true,         -- whether to automatically load preview when
                            -- entering another markdown buffer
  close_on_bdelete = true,  -- close preview window on buffer delete

  syntax = true,            -- enable syntax highlighting, affects performance

  theme = 'dark',           -- 'dark' or 'light'

  update_on_change = true,

  app = 'webview',          -- 'webview', 'browser', string or a table of strings
                            -- explained below

  filetype = { 'markdown' },-- list of filetypes to recognize as markdown

  -- relevant if update_on_change is true
  throttle_at = 200000,     -- start throttling when file exceeds this
                            -- amount of bytes in size
  throttle_time = 'auto',   -- minimum amount of time in milliseconds
                            -- that has to pass before starting new render
})

๐Ÿ“Ž app option

Preview opens in a webview window by default. You can set this option to 'browser' (will use your default browser as previewer) or specify browser along with arguments:

app = 'chromium'

app = { 'chromium', '--new-window' }

Chromium based browser is recommended.

๐Ÿ’ก Usage

method
open Open preview window
close Close preview window
is_open Returns true if preview window is currently open

Example command setup:

vim.api.nvim_create_user_command('PeekOpen', require('peek').open, {})
vim.api.nvim_create_user_command('PeekClose', require('peek').close, {})

The following keybinds are active when preview window is focused:

key
k scroll up
j scroll down
u scroll up half a page
d scroll down half a page
g scroll to top
G scroll to bottom

๐Ÿ” Preview window

Use your window manager to set preview window properties. Window title is Peek preview.

i3wm examples:

# do not focus preview window on open
no_focus [title="^Peek preview$"]

Use i3-msg to manipulate current layout and open preview window at desired position:

local peek = require('peek')

vim.api.nvim_create_user_command('PeekOpen', function()
  if not peek.is_open() and vim.bo[vim.api.nvim_get_current_buf()].filetype == 'markdown' then
    vim.fn.system('i3-msg split horizontal')
    peek.open()
  end
end, {})

vim.api.nvim_create_user_command('PeekClose', function()
  if peek.is_open() then
    peek.close()
    vim.fn.system('i3-msg move left')
  end
end, {})

peek.nvim's People

Contributors

toppair avatar hulufei avatar jakenvac avatar 0xadk avatar liamsnow avatar saimo avatar stephengolub avatar sushritpasupuleti avatar ataquino avatar djdv avatar fmorroni avatar tom-kuca avatar

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.