Skip to content

Commit

Permalink
Add configuration to enable color invert (#17)
Browse files Browse the repository at this point in the history
* Added config option for inverting colors

* Updated docs and readme to match new config option

* single quote in documentation

---------

Co-authored-by: chomosuke <[email protected]>
  • Loading branch information
AxiomOfChoices and chomosuke authored Jan 29, 2024
1 parent 38f125e commit b0fed1d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions doc/typst-preview.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions lua/typst-preview/config.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local M = {
opts = {
open_cmd = nil,
invert_colors = 'never',
debug = false,
get_root = function(_)
return vim.fn.getcwd()
Expand Down
2 changes: 2 additions & 0 deletions lua/typst-preview/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit b0fed1d

Please sign in to comment.