Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow configuration of extra args #45

Merged
merged 1 commit into from
Aug 25, 2024
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ require 'typst-preview'.setup {
['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 project
get_root = function(path_of_main_file)
return vim.fn.fnamemodify(path_of_main_file, ':p:h')
Expand Down
5 changes: 5 additions & 0 deletions doc/typst-preview.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ Warning: Be aware that your version might be older than the one
required.
Type: `table`, Default: `{['typst-preview'] = nil, ['websocat'] = nil}`

*typst-preview.extra_args*
A list of extra arguments (or nil) to be passed to previewer.
For example, `{ "--input=ver=draft", "--ignore-system-fonts" }`
Type: `table`, Default: `nil`

*typst-preview.get_main_file*
This function will be called to determine the main file of the typst project

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 @@ -8,6 +8,7 @@ local M = {
['typst-preview'] = nil,
['websocat'] = nil,
},
extra_args = nil,
get_root = function(path)
return vim.fn.fnamemodify(path, ':p:h')
end,
Expand Down
7 changes: 7 additions & 0 deletions lua/typst-preview/servers/factory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ local function spawn(path, mode, callback)
if typst_preview_bin:find 'tinymist' then
table.insert(args, 1, 'preview')
end

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

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