Skip to content
项目

关于

Neovim 的实时预览插件,可在网页浏览器中查看 Markdown、HTML(以及 CSS、JavaScript)、AsciiDoc 和 SVG 文件,并实时更新。

网站与应用开发

这些数字如何统计

可以做什么

  • Preview Markdown, AsciiDoc, SVG with live updates as you type
  • Preview HTML (with CSS and JavaScript) with live updates as you save the file
  • Supports KaTeX and Mermaid for rendering math equations and diagrams in Markdown and AsciiDoc files
  • Syntax highlighting for code blocks in Markdown and AsciiDoc 🖍️

实测星标增长

24小时
+1
7天
+3
15天
+5
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Introduction :wave:

LuaRocks

live-preview.nvim is a plugin for Neovim that allows you to view Markdown, HTML (along with CSS, JavaScript), AsciiDoc and SVG files in a web browser with live updates. No external dependencies or runtime like NodeJS or Python are required, since the backend is fully written in Lua and Neovim's built-in functions.

Features :sparkles:

  • Preview Markdown, AsciiDoc, SVG with live updates as you type
  • Preview HTML (with CSS and JavaScript) with live updates as you save the file
  • Supports KaTeX and Mermaid for rendering math equations and diagrams in Markdown and AsciiDoc files
  • Syntax highlighting for code blocks in Markdown and AsciiDoc 🖍️
  • Supports sync scrolling in the browser as you scroll in the Markdown files in Neovim.
  • Integration with telescope.nvim 🔭, fzf-lua, mini.pick and vim.ui.select meaning pickers like snacks.nvim is supported

Updates :loudspeaker:

See RELEASE.md

⚠️ Important Notice: You should clear the cache of the browser after updating to ensure the plugin works correctly.

Demo video :movie_camera:

https://github.com/user-attachments/assets/865112c1-8514-4920-a531-b2204194f749

Installation :package:

Requirements

  • Neovim >=0.10.1
  • A modern web browser
  • PowerShell (only if you use Windows)

You can install this plugin using a plugin manager. Most plugin managers are supported. Below are some examples

Using lazy.nvim (recommended) 💤
{
    'brianhuster/live-preview.nvim',
    dependencies = {
        -- You can choose one of the following pickers
        'nvim-telescope/telescope.nvim',
        'ibhagwan/fzf-lua',
        'echasnovski/mini.pick',
		'folke/snacks.nvim',
    },
}
mini.deps 📦
MiniDeps.add({
    source = 'brianhuster/live-preview.nvim',
    depends = { 
        -- You can choose one of the following pickers
        'nvim-telescope/telescope.nvim',
        'ibhagwan/fzf-lua',
        'echasnovski/mini.pick',
		'folke/snacks.nvim',
    }, 
})
rocks.nvim 🪨
:Rocks install live-preview.nvim
vim-plug 🔌
Plug 'brianhuster/live-preview.nvim'

" You can choose one of the following pickers
Plug 'nvim-telescope/telescope.nvim'
Plug 'ibhagwan/fzf-lua'
Plug 'echasnovski/mini.pick'
Plug 'folke/snacks.nvim'
Native package (without a plugin manager) 📦
git clone --depth 1 https://github.com/brianhuster/live-preview.nvim ~/.local/share/nvim/site/pack/brianhuster/start/live-preview.nvim
nvim -c 'helptags ~/.local/share/nvim/site/pack/brianhuster/start/live-preview.nvim/doc' -c 'q'

You may need to run helptags ALL in Neovim to generate the help tags, if your plugin manager does not do it for you.

Note for HTML

This plugin supports live-previewing Markdown, AsciiDoc and SVG files without the need to save the file. However, for HTML files, the preview will only be updated when you save the file.

You can create an autocmd that auto save the file when you leave insert mode.

--- Lua
vim.o.autowriteall = true
vim.api.nvim_create_autocmd({ 'InsertLeavePre', 'TextChanged', 'TextChangedP' }, {
    pattern = '*', callback = function()
        vim.cmd('silent! write')
    end
})
" Vimscript
set autowriteall
autocmd InsertLeavePre,TextChanged,TextChangedP * silent! write

Configuration, usage, FAQ

You can configure this plugin by passing a table to the Lua function

require('livepreview.config').set()

See :h livepreview for all configurations options, as well as usage and FAQ.

Contributing :handshake:

Since this is a young project, there should be a lot of rooms for improvements. If you would like to contribute to this project, please feel free to open an issue or a pull request.

Roadmap :rocket:

See TODO

Acknowledgements 🙏

Buy me a coffee ☕

Maintaining this project takes time and effort, especially as I am a student now. If you find this project helpful, please consider supporting me :>

Paypal VietQR

Alternatives

See Wiki for alternatives to live-preview.nvim

探索相关项目

加载中…