From 1bd0ae5f7e795376e2f262dd8e2886e7fd4083c2 Mon Sep 17 00:00:00 2001 From: Soliprem <73885403+Soliprem@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:10:40 +0100 Subject: [PATCH 1/4] typst: added tinymist and activated formatters (#444) * typst: added tinymist and activated formatters * docs: added tinymist release notes * typst: formatting * docs: complying with standards * typst: formatting --- docs/release-notes/rl-0.7.md | 1 + modules/plugins/languages/typst.nix | 57 +++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 00cfdac0..c20793ad 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -302,6 +302,7 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to `vim.languages.kotlin` - changed default keybinds for leap.nvim to avoid altering expected behavior - Add LSP, formatter and Treesitter support for Vala under `vim.languages.vala` +- Add [Tinymist](https://github.com/Myriad-Dreamin/tinymist] as a formatter for the Typst language module. [Bloxx12](https://github.com/Bloxx12) diff --git a/modules/plugins/languages/typst.nix b/modules/plugins/languages/typst.nix index da63c54e..c2ba7102 100644 --- a/modules/plugins/languages/typst.nix +++ b/modules/plugins/languages/typst.nix @@ -14,6 +14,38 @@ cfg = config.vim.languages.typst; + defaultServer = "tinymist"; + servers = { + typst-lsp = { + package = pkgs.typst-lsp; + lspConfig = '' + lspconfig.typst_lsp.setup { + capabilities = capabilities, + on_attach = default_on_attach, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/typst-lsp"}'' + }, + } + ''; + }; + tinymist = { + package = pkgs.tinymist; + lspConfig = '' + lspconfig.tinymist.setup { + capabilities = capabilities, + on_attach = default_on_attach, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/tinymist"}'' + }, + } + ''; + }; + }; + defaultFormat = "typstfmt"; formats = { typstfmt = { @@ -52,11 +84,17 @@ in { lsp = { enable = mkEnableOption "Typst LSP support (typst-lsp)" // {default = config.vim.languages.enableLSP;}; + server = mkOption { + description = "Typst LSP server to use"; + type = enum (attrNames servers); + default = defaultServer; + }; + package = mkOption { description = "typst-lsp package, or the command to run as a list of strings"; example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]''; type = either package (listOf str); - default = pkgs.typst-lsp; + default = servers.${cfg.lsp.server}.package; }; }; @@ -82,19 +120,14 @@ in { vim.treesitter.grammars = [cfg.treesitter.package]; }) + (mkIf cfg.format.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources.typst-format = formats.${cfg.format.type}.nullConfig; + }) + (mkIf cfg.lsp.enable { vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.typst-lsp = '' - lspconfig.typst_lsp.setup { - capabilities = capabilities, - on_attach=default_on_attach, - cmd = ${ - if isList cfg.lsp.package - then expToLua cfg.lsp.package - else ''{"${cfg.lsp.package}/bin/typst-lsp"}'' - }, - } - ''; + vim.lsp.lspconfig.sources.typst-lsp = servers.${cfg.lsp.server}.lspConfig; }) ]); } From 0ba3ccdab8b4150ca80ff6a40cc9261db27c2270 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 8 Nov 2024 19:47:01 +0300 Subject: [PATCH 2/4] modules: add `config.vim` to built package's passthru Accessible under `.passthru.neovimConfiguration` --- docs/release-notes/rl-0.7.md | 7 +++++-- modules/default.nix | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index c20793ad..f9eba716 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -285,6 +285,9 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to - Add [](#opt-vim.spellcheck.extraSpellWords) to allow adding arbitrary spellfiles to Neovim's runtime with ease. +- Add combined nvf configuration (`config.vim`) into the final package's + passthru as `passthru.neovimConfiguration` for easier debugging. + [ppenguin](https://github.com/ppenguin): - Telescope: @@ -302,7 +305,8 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to `vim.languages.kotlin` - changed default keybinds for leap.nvim to avoid altering expected behavior - Add LSP, formatter and Treesitter support for Vala under `vim.languages.vala` -- Add [Tinymist](https://github.com/Myriad-Dreamin/tinymist] as a formatter for the Typst language module. +- Add [Tinymist](https://github.com/Myriad-Dreamin/tinymist] as a formatter for + the Typst language module. [Bloxx12](https://github.com/Bloxx12) @@ -327,4 +331,3 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to [Nowaaru](https://github.com/Nowaaru): - Add `precognition-nvim`. - diff --git a/modules/default.nix b/modules/default.nix index 6306da9a..ee7febd4 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -123,6 +123,11 @@ in { paths = [neovim-wrapped printConfig printConfigPath]; postBuild = "echo Helpers added"; + # Allow evaluating vimOptions, i.e., config.vim from the packages' passthru + # attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig + # will return the configuration in full. + passthru.neovimConfig = vimOptions; + meta = { description = "Wrapped version of Neovim with additional helper scripts"; mainProgram = "nvim"; From b302e151e17b1de924d98868803b9ea9658d7043 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Fri, 8 Nov 2024 18:46:15 +0100 Subject: [PATCH 3/4] devicon: re-enable icon color was mistakenly disabled in a6bb6e1b3e360a1222bdc877633ac37440f1d4d2 --- modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix b/modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix index 7883486c..2796a5e6 100644 --- a/modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix +++ b/modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix @@ -16,7 +16,7 @@ in { enable = mkEnableOption "Neovim dev icons [nvim-web-devicons]"; setupOpts = mkPluginSetupOption "nvim-web-devicons" { - color_icons = mkEnableOption "different highlight colors per icon"; + color_icons = mkEnableOption "different highlight colors per icon" // {default = true;}; variant = mkOption { type = nullOr (enum ["light" "dark"]); default = null; From dfdad4c2cee7bad1a0f16db3d091f7a1e9f7247c Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Fri, 8 Nov 2024 19:03:01 +0100 Subject: [PATCH 4/4] lazy: update lazy.plugins default --- modules/wrapper/lazy/lazy.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/wrapper/lazy/lazy.nix b/modules/wrapper/lazy/lazy.nix index 5b2c53d1..7ea943ef 100644 --- a/modules/wrapper/lazy/lazy.nix +++ b/modules/wrapper/lazy/lazy.nix @@ -189,7 +189,7 @@ in { }; plugins = mkOption { - default = []; + default = {}; type = attrsOf lznPluginType; description = '' Plugins to lazy load.