meta-balena:实践指南
2026-09-12
2026-09-12 0
在项目中评估typst-preview.nvim,可以先看清用途边界:Neovim 的低延迟打字机预览。一旦进入日常自动化环节,输入边界、依赖和失败处理如果不清楚就很难稳定复用会直接影响交付,这也是我最关心的风险。更实际的做法是用一项范围明确的真实任务完成最小试跑,同时核对配置时间、输出质量、异常信息和维护痕迹,不要直接在关键项目上。如果团队属于愿意先做小范围验证并复查原始文档的团队,它有继续测试的理由;否则先看替代方案会更省时间。
✨ Typst Preview for Neovim ✨
Myriad-Dreamin/tinymist 的 Neovim 插件。
https://github.com/chomosuke/typst-preview.nvim/assets/38484873/9f8ecf0f-aa1c-4edb-85a9-96a8005e8f25
特点
安装
依赖关系
Lazy.nvim:
{
'chomosuke/typst-preview.nvim',
lazy = false, -- or ft = 'typst'
version = '1.*',
opts = {}, -- lazy.nvim will implicitly calls `setup {}`
}
Packer.nvim:
use {
'chomosuke/typst-preview.nvim',
tag = 'v1.*',
config = function()
require 'typst-preview'.setup {}
end,
}
vim 插件:
Plug 'chomosuke/typst-preview.nvim', {'tag': 'v1.*'}
注意: 您可以通过固定此的次要版本来固定打字员的次要版本
插件,i.e.,v1.1.* 而不是 v1.*。
用法
命令/功能:
:TypstPreviewUpdate 或 require 'typst-preview'.update():
vim.fn.fnamemodify(vim.fn.stdpath 'data' .. '/typst-preview/', ':p').setup {}.:TypstPreview:
:TypstPreview document (default) or :TypstPreview slide for slide mode.:TypstPreviewStop:
:TypstPreviewToggle:
:TypstPreviewFollowCursor 或 require 'typst-preview'.set_follow_cursor(true):
:TypstPreviewNoFollowCursor 或 require 'typst-preview'.set_follow_cursor(false):
:TypstPreviewFollowCursorToggle 或
require 'typst-preview'.set_follow_cursor(not init.get_follow_cursor()).:TypstPreviewSyncCursor 或 require 'typst-preview'.sync_with_cursor():
:TypstPreviewNoFollowCursor so that the preview only scroll to the current cursor position
when you want it to.⚙配置
该插件应该开箱即用,无需配置。然而,调用
需要 setup() 以确保插件依赖的二进制文件是
已经下载并且是最新的。
默认
require 'typst-preview'.setup {
-- Setting this true will enable logging debug information to
-- `vim.fn.stdpath 'data' .. '/typst-preview/log.txt'`
debug = false,
-- Custom format string to open the output link provided with %s
-- Example: open_cmd = 'firefox %s -P typst-preview --class typst-preview'
open_cmd = nil,
-- Custom port to open the preview server. Default is random.
-- Example: port = 8000
port = 0,
-- Custom host to bind the preview server to.
-- Note that '0.0.0.0' is not supported and [won't be](https://github.com/Myriad-Dreamin/tinymist/issues/2105)
-- Example: host = '192.168.0.10'
host = '127.0.0.1',
-- Setting this to 'always' will invert black and white in the preview
-- Setting this to 'auto' will invert depending if the browser has enable
-- dark mode
-- Setting this to '{"rest": "
使用Mason安装的tinymist
将 dependencies_bin 选项设置为
dependencies_bin = { tinymist = 'tinymist' } 或,在 Windows 上
dependencies_bin = { tinymist = 'tinymist.cmd' } 应指向
梅森安装tinymist。
❓ 与其他工具的比较
Enter-tainer/typst-preview 的作者写了一篇 很好比较这里的here。