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] 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 f5e9d0a0..b7396cbe 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 e1417c86..62efe9ed 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 415f1b67..33ea9588 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";}) + ]; + }; }) ]); }