From ed3be410c591c9bfaf28fcaec29c0ef47b7dbb09 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 9 Dec 2024 09:28:18 +0300 Subject: [PATCH 1/2] meta: update release info (0.8) --- release.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release.json b/release.json index 28c5eb7f..a80b41ea 100644 --- a/release.json +++ b/release.json @@ -1,4 +1,4 @@ { - "release": "v0.7", - "isReleaseBranch": true + "release": "v0.8", + "isReleaseBranch": false } From a36935236564323b3fa37d5be9056bc91e18c7f7 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 9 Dec 2024 09:28:23 +0300 Subject: [PATCH 2/2] languages/typst: add `typst-preview.nvim` as an extension --- docs/release-notes/rl-0.8.md | 8 ++++ flake.lock | 17 ++++++++ flake.nix | 5 +++ modules/plugins/languages/typst.nix | 62 +++++++++++++++++++++++++++-- 4 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 docs/release-notes/rl-0.8.md diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md new file mode 100644 index 00000000..128ecd19 --- /dev/null +++ b/docs/release-notes/rl-0.8.md @@ -0,0 +1,8 @@ +# Release 0.8 {#sec-release-0.8} + +[NotAShelf](https://github.com/notashelf): + +[typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim + +- Add [typst-preview.nvim] under + `languages.typst.extensions.typst-preview-nvim`. diff --git a/flake.lock b/flake.lock index e84beb3a..d5532b4b 100644 --- a/flake.lock +++ b/flake.lock @@ -1902,6 +1902,22 @@ "type": "github" } }, + "plugin-typst-preview-nvim": { + "flake": false, + "locked": { + "lastModified": 1733120663, + "narHash": "sha256-uYMZ2PONiiI3UDvCgNvyy4+jhzmUDbAyxX0phKxELXw=", + "owner": "chomosuke", + "repo": "typst-preview.nvim", + "rev": "0cb5f5627312f50ce089f785ec42b55a85f30ce7", + "type": "github" + }, + "original": { + "owner": "chomosuke", + "repo": "typst-preview.nvim", + "type": "github" + } + }, "plugin-vim-dirtytalk": { "flake": false, "locked": { @@ -2151,6 +2167,7 @@ "plugin-tokyonight": "plugin-tokyonight", "plugin-trouble": "plugin-trouble", "plugin-ts-error-translator": "plugin-ts-error-translator", + "plugin-typst-preview-nvim": "plugin-typst-preview-nvim", "plugin-vim-dirtytalk": "plugin-vim-dirtytalk", "plugin-vim-fugitive": "plugin-vim-fugitive", "plugin-vim-illuminate": "plugin-vim-illuminate", diff --git a/flake.nix b/flake.nix index e52f9416..65c802f2 100644 --- a/flake.nix +++ b/flake.nix @@ -206,6 +206,11 @@ flake = false; }; + plugin-typst-preview-nvim = { + url = "github:chomosuke/typst-preview.nvim"; + 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 fbb090e8..24097e2c 100644 --- a/modules/plugins/languages/typst.nix +++ b/modules/plugins/languages/typst.nix @@ -7,10 +7,13 @@ inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; inherit (lib.lists) isList; - inherit (lib.types) enum either listOf package str; + inherit (lib.types) nullOr enum either attrsOf listOf package str; inherit (lib.attrsets) attrNames; - inherit (lib.nvim.lua) expToLua; - inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.generators) mkLuaInline; + inherit (lib.meta) getExe; + inherit (lib.nvim.lua) expToLua toLuaObject; + inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.languages.typst; @@ -33,6 +36,7 @@ } ''; }; + tinymist = { package = pkgs.tinymist; lspConfig = '' @@ -120,6 +124,50 @@ in { default = formats.${cfg.format.type}.package; }; }; + + extensions = { + typst-preview-nvim = { + enable = + mkEnableOption '' + [typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim + + Low latency typst preview for Neovim via [typst-preview.nvim] + '' + // {default = true;}; + + setupOpts = mkPluginSetupOption "typst-preview-nvim" { + open_cmd = mkOption { + type = nullOr str; + default = null; + example = "firefox %s -P typst-preview --class typst-preview"; + description = '' + Custom format string to open the output link provided with `%s` + ''; + }; + + dependencies_bin = mkOption { + type = attrsOf str; + default = { + "tinymist" = getExe servers.tinymist.package; + "websocat" = getExe pkgs.websocat; + }; + + description = '' + Provide the path to binaries for dependencies. Setting this + to a non-null value will skip the download of the binary by + the plugin. + ''; + }; + + extra_args = mkOption { + type = nullOr (listOf str); + default = null; + example = ["--input=ver=draft" "--ignore-system-fonts"]; + description = "A list of extra arguments (or `null`) to be passed to previewer"; + }; + }; + }; + }; }; config = mkIf cfg.enable (mkMerge [ (mkIf cfg.treesitter.enable { @@ -136,5 +184,13 @@ in { vim.lsp.lspconfig.enable = true; vim.lsp.lspconfig.sources.typst-lsp = servers.${cfg.lsp.server}.lspConfig; }) + + # Extensions + (mkIf cfg.extensions.typst-preview-nvim.enable { + vim.startPlugins = ["typst-preview-nvim"]; + vim.pluginRC.typst-preview-nvim = entryAnywhere '' + require("typst-preview").setup(${toLuaObject cfg.extensions.typst-preview-nvim.setupOpts}) + ''; + }) ]); }