From d9448d8ed3ea2ccefc1f414d05e0761b5255bb58 Mon Sep 17 00:00:00 2001 From: PartyWumpus <48649272+PartyWumpus@users.noreply.github.com> Date: Mon, 27 Jan 2025 02:53:46 +0000 Subject: [PATCH 1/7] add typst-concealer --- flake.lock | 17 ++++++++++ flake.nix | 5 +++ modules/plugins/languages/typst.nix | 51 ++++++++++++++++++++++++++++- 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/flake.lock b/flake.lock index ee19b7c8e..e1417c863 100644 --- a/flake.lock +++ b/flake.lock @@ -2633,6 +2633,22 @@ "type": "github" } }, + "plugin-typst-concealer": { + "flake": false, + "locked": { + "lastModified": 1737944956, + "narHash": "sha256-YCkxM1xqY3gTrKVzRFI4fedOzhEeIq/dnYya/MST6Qo=", + "owner": "PartyWumpus", + "repo": "typst-concealer", + "rev": "e3d5bc44dc4ea9d68f3cee271eee1a75ff7d59e9", + "type": "github" + }, + "original": { + "owner": "PartyWumpus", + "repo": "typst-concealer", + "type": "github" + } + }, "plugin-typst-preview-nvim": { "flake": false, "locked": { @@ -2926,6 +2942,7 @@ "plugin-tokyonight": "plugin-tokyonight", "plugin-trouble": "plugin-trouble", "plugin-ts-error-translator": "plugin-ts-error-translator", + "plugin-typst-concealer": "plugin-typst-concealer", "plugin-typst-preview-nvim": "plugin-typst-preview-nvim", "plugin-vim-dirtytalk": "plugin-vim-dirtytalk", "plugin-vim-fugitive": "plugin-vim-fugitive", diff --git a/flake.nix b/flake.nix index 5d4728f66..fc36930cf 100644 --- a/flake.nix +++ b/flake.nix @@ -210,6 +210,11 @@ flake = false; }; + plugin-typst-concealer = { + url = "github:PartyWumpus/typst-concealer"; + flake = false; + }; + plugin-nvim-metals = { url = "github:scalameta/nvim-metals"; flake = false; diff --git a/modules/plugins/languages/typst.nix b/modules/plugins/languages/typst.nix index 24097e2c5..1c0902673 100644 --- a/modules/plugins/languages/typst.nix +++ b/modules/plugins/languages/typst.nix @@ -7,7 +7,7 @@ inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; inherit (lib.lists) isList; - inherit (lib.types) nullOr enum either attrsOf listOf package str; + inherit (lib.types) nullOr enum either attrsOf listOf package str bool int; inherit (lib.attrsets) attrNames; inherit (lib.generators) mkLuaInline; inherit (lib.meta) getExe; @@ -167,6 +167,48 @@ in { }; }; }; + typst-concealer = { + enable = + mkEnableOption '' + [typst-concealer]: https://github.com/PartyWumpus/typst-concealer + + Inline typst preview for Neovim via [typst-concealer] + '' + // {default = false;}; + + setupOpts = mkPluginSetupOption "typst-concealer" { + do_diagnostics = mkOption { + type = nullOr bool; + description = ''Should typst-concealer provide diagnostics on error?''; + default = !cfg.lsp.enable; + }; + color = mkOption { + type = nullOr str; + description = ''What color should typst-concealer render text/stroke with? (only applies when styling_type is "colorscheme")''; + default = null; + }; + enabled_by_default = mkOption { + type = nullOr bool; + description = ''Should typst-concealer conceal newly opened buffers by default?''; + default = null; + }; + styling_type = mkOption { + type = nullOr (enum ["simple" "none" "colorscheme"]); + description = ''What kind of styling should typst-concealer apply to your typst?''; + default = null; + }; + ppi = mkOption { + type = nullOr int; + description = ''What PPI should typst render at. Plugin default is 300, typst's normal default is 144.''; + default = null; + }; + typst_location = mkOption { + type = str; + default = getExe pkgs.typst; + description = ''Where should typst-concealer look for your typst binary?''; + }; + }; + }; }; }; config = mkIf cfg.enable (mkMerge [ @@ -192,5 +234,12 @@ in { require("typst-preview").setup(${toLuaObject cfg.extensions.typst-preview-nvim.setupOpts}) ''; }) + + (mkIf cfg.extensions.typst-concealer.enable { + vim.startPlugins = ["typst-concealer"]; + vim.pluginRC.typst-concealer = entryAnywhere '' + require("typst-concealer").setup(${toLuaObject cfg.extensions.typst-concealer.setupOpts}) + ''; + }) ]); } From 0738bd5b187657873e1b884ea6b23a2e42b3bd59 Mon Sep 17 00:00:00 2001 From: Party Wumpus <48649272+PartyWumpus@users.noreply.github.com> Date: Mon, 27 Jan 2025 04:51:19 +0000 Subject: [PATCH 2/7] Update modules/plugins/languages/typst.nix Co-authored-by: raf --- modules/plugins/languages/typst.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/plugins/languages/typst.nix b/modules/plugins/languages/typst.nix index 1c0902673..415f1b679 100644 --- a/modules/plugins/languages/typst.nix +++ b/modules/plugins/languages/typst.nix @@ -173,8 +173,7 @@ in { [typst-concealer]: https://github.com/PartyWumpus/typst-concealer Inline typst preview for Neovim via [typst-concealer] - '' - // {default = false;}; + ''; setupOpts = mkPluginSetupOption "typst-concealer" { do_diagnostics = mkOption { From 0ebeca8f3947ea586325b1a5632d7a28912a05e3 Mon Sep 17 00:00:00 2001 From: PartyWumpus <48649272+PartyWumpus@users.noreply.github.com> Date: Mon, 27 Jan 2025 05:56:16 +0000 Subject: [PATCH 3/7] add keybinds, resolve review etc --- docs/release-notes/rl-0.8.md | 6 +++++ flake.lock | 6 ++--- modules/plugins/languages/typst.nix | 41 ++++++++++++++++++----------- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index f5e9d0a04..b7396cbe5 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -135,3 +135,9 @@ - Add `vim.languages.zig.dap` support through pkgs.lldb dap adapter. Code Inspiration from `vim.languages.clang.dap` implementation. + +PartyWumpus: + +[typst-concealer]: https://github.com/PartyWumpus/typst-concealer + +- Add inline typst concealing support under `vim.languages.typst` using [typst-concealer]. diff --git a/flake.lock b/flake.lock index e1417c863..62efe9edb 100644 --- a/flake.lock +++ b/flake.lock @@ -2636,11 +2636,11 @@ "plugin-typst-concealer": { "flake": false, "locked": { - "lastModified": 1737944956, - "narHash": "sha256-YCkxM1xqY3gTrKVzRFI4fedOzhEeIq/dnYya/MST6Qo=", + "lastModified": 1737954973, + "narHash": "sha256-DV5RNMAdSePc5T3XAAGAbY5LB1G5tapQxtJEhT8DtDY=", "owner": "PartyWumpus", "repo": "typst-concealer", - "rev": "e3d5bc44dc4ea9d68f3cee271eee1a75ff7d59e9", + "rev": "e7ff35c359a7c8cf375cb02a97b23e76bd9bbe57", "type": "github" }, "original": { diff --git a/modules/plugins/languages/typst.nix b/modules/plugins/languages/typst.nix index 415f1b679..33ea95888 100644 --- a/modules/plugins/languages/typst.nix +++ b/modules/plugins/languages/typst.nix @@ -11,6 +11,7 @@ inherit (lib.attrsets) attrNames; inherit (lib.generators) mkLuaInline; inherit (lib.meta) getExe; + inherit (lib.nvim.binds) mkMappingOption mkKeymap; inherit (lib.nvim.lua) expToLua toLuaObject; inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; inherit (lib.nvim.dag) entryAnywhere; @@ -168,43 +169,47 @@ in { }; }; typst-concealer = { - enable = - mkEnableOption '' - [typst-concealer]: https://github.com/PartyWumpus/typst-concealer + enable = mkEnableOption '' + [typst-concealer]: https://github.com/PartyWumpus/typst-concealer + + Inline typst preview for Neovim via [typst-concealer] + ''; - Inline typst preview for Neovim via [typst-concealer] - ''; + mappings = { + toggleConcealing = mkMappingOption "Enable typst-concealer in buffer" "TT"; + }; setupOpts = mkPluginSetupOption "typst-concealer" { do_diagnostics = mkOption { type = nullOr bool; - description = ''Should typst-concealer provide diagnostics on error?''; default = !cfg.lsp.enable; + description = "Should typst-concealer provide diagnostics on error?"; }; color = mkOption { type = nullOr str; - description = ''What color should typst-concealer render text/stroke with? (only applies when styling_type is "colorscheme")''; default = null; + example = "rgb(\"#f012be\")"; + description = "What color should typst-concealer render text/stroke with? (only applies when styling_type is 'colorscheme')"; }; enabled_by_default = mkOption { type = nullOr bool; - description = ''Should typst-concealer conceal newly opened buffers by default?''; default = null; + description = "Should typst-concealer conceal newly opened buffers by default?"; }; styling_type = mkOption { type = nullOr (enum ["simple" "none" "colorscheme"]); - description = ''What kind of styling should typst-concealer apply to your typst?''; default = null; + description = "What kind of styling should typst-concealer apply to your typst?"; }; ppi = mkOption { type = nullOr int; - description = ''What PPI should typst render at. Plugin default is 300, typst's normal default is 144.''; default = null; + description = "What PPI should typst render at. Plugin default is 300, typst's normal default is 144."; }; typst_location = mkOption { type = str; default = getExe pkgs.typst; - description = ''Where should typst-concealer look for your typst binary?''; + description = "Where should typst-concealer look for your typst binary?"; }; }; }; @@ -235,10 +240,16 @@ in { }) (mkIf cfg.extensions.typst-concealer.enable { - vim.startPlugins = ["typst-concealer"]; - vim.pluginRC.typst-concealer = entryAnywhere '' - require("typst-concealer").setup(${toLuaObject cfg.extensions.typst-concealer.setupOpts}) - ''; + vim.lazy.plugins.typst-concealer = { + event = "BufRead *.typ"; + package = "typst-concealer"; + setupModule = "typst-concealer"; + setupOpts = cfg.extensions.typst-concealer.setupOpts; + + keys = [ + (mkKeymap "n" cfg.extensions.typst-concealer.mappings.toggleConcealing "lua require('typst-concealer').toggle_buf()" {desc = "Toggle typst-concealer in buffer";}) + ]; + }; }) ]); } From c4a62259d2aa8213d021105040389d1ebccb10b1 Mon Sep 17 00:00:00 2001 From: PartyWumpus <48649272+PartyWumpus@users.noreply.github.com> Date: Wed, 17 Sep 2025 19:15:54 +0100 Subject: [PATCH 4/7] add changes back (it was easier than a rebase here) --- docs/release-notes/rl-0.8.md | 6 ++++++ npins/sources.json | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 74a94b9c7..0c9346700 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -499,3 +499,9 @@ - Add [nvim-highlight-colors] plugin in `vim.ui.nvim-highlight-colors` with `enable` and `setupOpts` + +[PartyWumpus](https://github.com/PartyWumpus): + +[typst-concealer]: https://github.com/PartyWumpus/typst-concealer + +- Add inline typst concealing support under `vim.languages.typst` using [typst-concealer]. diff --git a/npins/sources.json b/npins/sources.json index cf4bb564a..ff8662f36 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -2526,6 +2526,19 @@ "url": "https://github.com/dmmulroy/ts-error-translator.nvim/archive/47e5ba89f71b9e6c72eaaaaa519dd59bd6897df4.tar.gz", "hash": "08whn7l75qv5n74cifmnxc0s7n7ja1g7589pjnbbsk2djn6bqbky" }, + "typst-concealer": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "PartyWumpus", + "repo": "typst-concealer" + }, + "branch": "main", + "submodules": false, + "revision": "3d2e72ce7fc06bd0db0dafbdd1e17d3c9e343d53", + "url": "https://github.com/PartyWumpus/typst-concealer/archive/3d2e72ce7fc06bd0db0dafbdd1e17d3c9e343d53.tar.gz", + "hash": "16j3q3hk1wzgcz6snn9997vclhkanplyn0cp1dm9lk034jd8v9nh" + }, "typst-preview-nvim": { "type": "Git", "repository": { From 1d17c4b24334e3134a3e45c82f8b2fabd0e770dd Mon Sep 17 00:00:00 2001 From: PartyWumpus <48649272+PartyWumpus@users.noreply.github.com> Date: Wed, 17 Sep 2025 19:21:05 +0100 Subject: [PATCH 5/7] add the newer conceal_in_normal option --- modules/plugins/languages/typst.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/plugins/languages/typst.nix b/modules/plugins/languages/typst.nix index da3b462dc..32bce6766 100644 --- a/modules/plugins/languages/typst.nix +++ b/modules/plugins/languages/typst.nix @@ -193,6 +193,12 @@ in { type = str; default = getExe pkgs.typst; description = "Where should typst-concealer look for your typst binary?"; + example = ''lib.getExe pkgs.typst''; + }; + conceal_in_normal = mkOption { + type = nullOr bool; + default = null; + description = "Should typst-concealer still conceal when the normal mode cursor goes over a line."; }; }; }; From 45c3838220f22e233a8465ab03b5b278f4b3f069 Mon Sep 17 00:00:00 2001 From: PartyWumpus <48649272+PartyWumpus@users.noreply.github.com> Date: Wed, 17 Sep 2025 19:25:23 +0100 Subject: [PATCH 6/7] run deno fmt --- docs/release-notes/rl-0.8.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 0c9346700..82b3c77e6 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -504,4 +504,5 @@ [typst-concealer]: https://github.com/PartyWumpus/typst-concealer -- Add inline typst concealing support under `vim.languages.typst` using [typst-concealer]. +- Add inline typst concealing support under `vim.languages.typst` using + [typst-concealer]. From 025c4162ccf83b1adbe5e39b4bc59cb5120094e5 Mon Sep 17 00:00:00 2001 From: PartyWumpus <48649272+PartyWumpus@users.noreply.github.com> Date: Wed, 17 Sep 2025 21:06:55 +0100 Subject: [PATCH 7/7] add "typ" to typos --- .github/typos.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/typos.toml b/.github/typos.toml index 2cd18dde2..26be7d9b6 100644 --- a/.github/typos.toml +++ b/.github/typos.toml @@ -5,6 +5,7 @@ default.extend-ignore-words-re = [ "befores", "annote", "viw", + "typ", "BA", # somehow "BANanaD3V" is valid, but BA is not... ]