警告
本文最后更新于 2024-03-13,文中内容可能已过时。
我现在基本上都是使用nvim做笔记,大部分的时间都是写 markdown 格式的文档。因此,需要一款能够在终端实时渲染的插件。
glow
glow
是一款可以在终端渲染 markdown 文档的命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# Debian/Ubuntu
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
sudo apt update && sudo apt install glow
# Fedora/RHEL
echo '[charm]
name=Charm
baseurl=https://repo.charm.sh/yum/
enabled=1
gpgcheck=1
gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo
sudo yum install glow
|
markdown-preview.nvim
这款插件支持在 nvim 的终端即可渲染 markdown,底层调用的是 glow
的渲染功能。
我这里配置了快捷键:mp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
-- :MPToggle: toggle markdown preview open or close.
-- :MPOpen: open markdown preview window.
-- :MPClose: close markdown preview window.
-- :MPRefresh: refresh markdown preview window.
return {
"0x00-ketsu/markdown-preview.nvim",
ft = {'md', 'markdown', 'mkd', 'mkdn', 'mdwn', 'mdown', 'mdtxt', 'mdtext', 'rmd', 'wiki'},
cmd = { "MPToggle", "MPOpen", "MPClose", "MPRefresh" },
config = function()
require('markdown-preview').setup {
-- 配置快捷键:mp
vim.keymap.set( "n", "mp", ":MPToggle<CR>", { silent = true }),
glow = {
-- When find executable path of `glow` failed (from PATH), use this value instead
exec_path = '',
style = '', -- Path to glamour JSON style file
},
-- Markdown preview term
term = {
-- reload term when rendered markdown file changed
reload = {
enable = true,
events = {
'InsertLeave',
'TextChanged'
},
},
direction = 'vertical', -- choices: vertical / horizontal
keys = {
close = {'q', '<Esc>'},
refresh = 'r',
}
}
}
end
}
|