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.
telescope.nvim
🔭, fzf-lua
, mini.pick
and vim.ui.select
meaning pickers like snacks.nvim
is supportedSee RELEASE.md
⚠️ Important Notice: You should clear the cache of the browser after updating to ensure the plugin works correctly.
https://github.com/user-attachments/assets/865112c1-8514-4920-a531-b2204194f749
Requirements
You can install this plugin using a plugin manager. Most plugin managers are supported. Below are some examples
{
'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',
},
}
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 install live-preview.nvim
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'
Plog 'folke/snacks.nvim'
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.
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
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.
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.
See TODO
Maintaining this project takes time and effort, especially as I am a student now. If you find this project helpful, please consider supporting me :>
See Wiki for alternatives to live-preview.nvim