The Neovim plugin for Enter-tainer/typst-preview.
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 = '0.1.*',
build = function() require 'typst-preview'.update() end,
}
Packer.nvim:
use {
'chomosuke/typst-preview.nvim',
tag = 'v0.1.*',
run = function() require 'typst-preview'.update() end,
}
vim-plug:
Plug 'chomosuke/typst-preview.nvim', {'tag': 'v0.1.*', do: ':TypstPreviewUpdate'}
:TypstPreviewUpdate
or require 'typst-preview'.update()
:vim.fn.fnamemodify(vim.fn.stdpath 'data' .. '/typst-preview/', ':p')
.:TypstPreview
::TypstPreviewStop
::TypstPreviewToggle
::TypstPreviewFollowCursor
or require 'typst-preview'.set_follow_cursor(true)
::TypstPreviewNoFollowCursor
or require 'typst-preview'.set_follow_cursor(false)
::TypstPreviewFollowCursorToggle
or
require 'typst-preview'.set_follow_cursor(not init.get_follow_cursor())
.:TypstPreviewSyncCursor
or require 'typst-preview'.sync_with_cursor()
::TypstPreviewNoFollowCursor
so that the preview only scroll to the current cursor position
when you want it to.This plugin should work out of the box with no configuration. Call to setup()
is not required.
require 'typst-preview'.setup {
-- Setting this true will enable printing debug information with print()
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,
-- 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 = {
['typst-preview'] = nil,
['websocat'] = nil
},
-- 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
invert_colors = 'never',
-- This function will be called to determine the root of the typst project
get_root = function(bufnr_of_typst_buffer)
return vim.fn.getcwd()
end,
}
The author of Enter-tainer/typst-preview wrote a good comparison here.
All PRs are welcome.
This plugin wouldn't be possible without the work of Enter-tainer/typst-preview. If you like this plugin enough to star it, please consider starring Enter-tainer/typst-preview as well.