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] 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 ee19b7c8..e1417c86 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 5d4728f6..fc36930c 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 24097e2c..1c090267 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}) + ''; + }) ]); }