Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ require 'typst-preview'.setup {
-- Example: port = 8000
port = 0,

-- Enable partial rendering or not
partial_rendering = true,

-- 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
Expand Down
4 changes: 4 additions & 0 deletions doc/typst-preview.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ Provide a custom port for the preview server. If the port (e.g. 8000) is
already in use, the plugin will try to use the next port (e.g. 8001).
Type: `number`, Default: `0` (i.e. random)

*typst-preview.partial_rendering*
Set this to false to disable partial rendering.
Type: `boolean`, Default: `true`

*typst-preview.invert_colors*
Can be used to invert colors in preview.
Set to `'never'` to disable.
Expand Down
1 change: 1 addition & 0 deletions lua/typst-preview/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local M = {
debug = false,
open_cmd = nil,
port = 0, -- tinymist will use a random port if this is 0
partial_rendering = true,
invert_colors = 'never',
follow_cursor = true,
dependencies_bin = {
Expand Down
8 changes: 6 additions & 2 deletions lua/typst-preview/servers/factory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ local function spawn(path, port, mode, callback)
or (utils.get_data_path() .. fetch.get_tinymist_bin_name())
local args = {
'preview',
'--partial-rendering',
'--invert-colors',
config.opts.invert_colors,
'--preview-mode',
Expand All @@ -31,15 +30,20 @@ local function spawn(path, port, mode, callback)
'127.0.0.1:' .. port,
'--root',
config.opts.get_root(path),
config.opts.get_main_file(path),
}

if config.opts.partial_rendering then
table.insert(args, '--partial-rendering')
end

if config.opts.extra_args ~= nil then
for _, v in ipairs(config.opts.extra_args) do
table.insert(args, v)
end
end

table.insert(args, config.opts.get_main_file(path))

local server_handle, _ = assert(vim.uv.spawn(tinymist_bin, {
args = args,
stdio = { nil, server_stdout, server_stderr },
Expand Down