diff --git a/README.md b/README.md index 3266647..d6feff6 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Plug 'chomosuke/typst-preview.nvim', {'tag': 'v0.1.*', do: ':TypstPreviewUpdate' - Don't scroll preview as cursor moves. - `:TypstPreviewFollowCursorToggle` or `require 'typst-preview'.set_follow_cursor(not init.get_follow_cursor())`. -- `:TypstPreviewSyncCursor` or `require 'typst-preview.sync_with_cursor()`: +- `:TypstPreviewSyncCursor` or `require '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 position when you want it to. @@ -83,6 +83,11 @@ require 'typst-preview'.setup { -- Example: open_cmd = 'firefox %s -P typst-preview --class typst-preview' open_cmd = 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() diff --git a/doc/typst-preview.nvim.txt b/doc/typst-preview.nvim.txt index d0854d6..3d01fd0 100644 --- a/doc/typst-preview.nvim.txt +++ b/doc/typst-preview.nvim.txt @@ -115,6 +115,13 @@ Provide a custom format string to open the output link in `%s`. Example value for open_cmd: `'firefox %s -P typst-preview --class typst-preview'`. Type: `string`, Default: `nil` +*typst-preview.invert_colors* +Can be used to invert colors in preview. +Set to `'never'` to disable. +Set to `'always'` to enable. +Set to `'auto'` to enable if environment (usually browser) has enabled darkmode. + Type: `string`, Default: `'never'` + *typst-preview.get_root* This function will be called to determine the root of the typst project diff --git a/lua/typst-preview/config.lua b/lua/typst-preview/config.lua index acd5002..9e25c8d 100644 --- a/lua/typst-preview/config.lua +++ b/lua/typst-preview/config.lua @@ -1,6 +1,7 @@ local M = { opts = { open_cmd = nil, + invert_colors = 'never', debug = false, get_root = function(_) return vim.fn.getcwd() diff --git a/lua/typst-preview/server.lua b/lua/typst-preview/server.lua index 1cc7a4e..e7b4e3e 100644 --- a/lua/typst-preview/server.lua +++ b/lua/typst-preview/server.lua @@ -30,6 +30,8 @@ function M.spawn(bufnr, callback, set_link) local server_handle, _ = assert(vim.loop.spawn(utils.get_data_path() .. fetch.get_typst_bin_name(), { args = { + '--invert-colors', + config.opts.invert_colors, '--no-open', '--data-plane-host', '127.0.0.1:0',