Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Low latency typst preview for Neovim

License

NotificationsYou must be signed in to change notification settings

chomosuke/typst-preview.nvim

Repository files navigation

Logo that represents the split screen workflow: an eye with NeoVim colours on one half (coding) and black and white on the other (preview); Typst’s logo is in the iris

✨ Typst Preview for Neovim ✨

The Neovim plugin forMyriad-Dreamin/tinymist.

trimmed.mp4

💪 Features

  • Low latency preview: preview your document instantly on type. The incremental rendering techniquemakes the preview latency as low as possible.
  • Cross jump between code and preview. You can click on the preview to jump to thecorresponding code location and have the preview follow your cursor in Neovim.

📦 Installation

Dependencies

  • curl

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:

Plug'chomosuke/typst-preview.nvim', {'tag':'v1.*'}

Note: You can pin typst's minor version by pinning the minor version of thisplugin, i.e.,v1.1.* instead ofv1.*.

🚀 Usage

Commands / Functions:

  • :TypstPreviewUpdate orrequire 'typst-preview'.update():
    • Download the necessary binaries tovim.fn.fnamemodify(vim.fn.stdpath 'data' .. '/typst-preview/', ':p').
    • This must be run before any other commands can be run. It is implicitly ranwhen callingsetup {}.
  • :TypstPreview:
    • Start the preview. Optionally, the desired preview mode can be specified::TypstPreview document (default) or:TypstPreview slide for slide mode.
  • :TypstPreviewStop:
    • Stop the preview.
  • :TypstPreviewToggle:
    • Toggle the preview.
  • :TypstPreviewFollowCursor orrequire 'typst-preview'.set_follow_cursor(true):
    • Scroll preview as cursor moves.
    • This is on by default.
  • :TypstPreviewNoFollowCursor orrequire 'typst-preview'.set_follow_cursor(false):
    • Don't scroll preview as cursor moves.
  • :TypstPreviewFollowCursorToggle orrequire 'typst-preview'.set_follow_cursor(not init.get_follow_cursor()).
  • :TypstPreviewSyncCursor orrequire 'typst-preview'.sync_with_cursor():
    • Scroll preview to the current cursor position. This can be used in combination with:TypstPreviewNoFollowCursor so that the preview only scroll to the current cursor positionwhen you want it to.

⚙️ Configuration

This plugin should work out of the box with no configuration. However, callingsetup() is required to ensure that the binaries that the plugin depends on aredownloaded and up to date.

Default

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 = 8000port=0,-- 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": "<option>","image": "<option>"}' will apply-- your choice of color inversion to images and everything else-- separately.invert_colors='never',-- Whether the preview will follow the cursor in the source filefollow_cursor=true,-- Provide the path to binaries for dependencies.-- Setting this will skip the download of the binary by the plugin.-- Warning: Be aware that your version might be older than the one-- required.dependencies_bin= {    ['tinymist']=nil,    ['websocat']=nil  },-- A list of extra arguments (or nil) to be passed to previewer.-- For example, extra_args = { "--input=ver=draft", "--ignore-system-fonts" }extra_args=nil,-- This function will be called to determine the root of the typst projectget_root=function(path_of_main_file)localroot=os.getenv'TYPST_ROOT'ifrootthenreturnrootendreturnvim.fn.fnamemodify(path_of_main_file,':p:h')end,-- This function will be called to determine the main file of the typst-- project.get_main_file=function(path_of_buffer)returnpath_of_bufferend,}

Use tinymist installed from Mason

Setdependencies_bin option todependencies_bin = { ['tinymist'] = 'tinymist' } should point towards theMason installation of tinymist.

❓ Comparison with other tools

The author ofEnter-tainer/typst-preview wrote agood comparisonhere.

  • niuiic/typst-preview.nvim: Since niuiic/typst-preview.nvim usestypst-lsp, it has similar advantages anddisadvantages of typst-lsp mentionedhere:
    • Higher latency due to the PDF reader having a delay.
    • Does not support cross jump between code and preview.

💻 Contribution

All PRs are welcome.

Credit

This plugin wouldn't be possible without the work ofEnter-tainer/typst-preview andMyriad-Dreamin/tinymist. If youlike this plugin enough to star it, please consider starringEnter-tainer/typst-preview andMyriad-Dreamin/tinymist as well.


[8]ページ先頭

©2009-2025 Movatter.jp