From 1a471ee95e1c7a69f15ce75b5f6b1fe9ede9a778 Mon Sep 17 00:00:00 2001 From: Flameopathic <64027365+Flameopathic@users.noreply.github.com> Date: Thu, 12 Jun 2025 17:28:51 +0200 Subject: [PATCH] neovim: combine Neovim, Neovide, NixVim, nvf, and Vim (#1377) Closes: https://github.com/nix-community/stylix/issues/1189 Link: https://github.com/nix-community/stylix/pull/1377 Reviewed-by: Adam M. Szalkowski Tested-by: Adam M. Szalkowski Reviewed-by: Matt Sturgeon Tested-by: NAHO <90870942+trueNAHO@users.noreply.github.com> Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com> --- doc/book.toml | 3 + doc/redirects.js | 2 +- modules/neovide/meta.nix | 6 -- modules/neovim/darwin.nix | 6 ++ modules/neovim/hm.nix | 87 ++----------------- modules/neovim/meta.nix | 85 ++++++++++++++++-- .../nixvim.nix => neovim/neovide-common.nix} | 0 .../{neovide/hm.nix => neovim/neovide.nix} | 2 +- modules/neovim/neovim.nix | 81 +++++++++++++++++ modules/neovim/nixos.nix | 6 ++ modules/{nixvim => neovim}/nixvim.nix | 2 +- modules/{nvf => neovim}/nvf.nix | 0 .../{neovide => neovim}/testbeds/neovide.nix | 0 modules/{vim/hm.nix => neovim/vim.nix} | 2 +- modules/nixvim/darwin.nix | 1 - modules/nixvim/hm.nix | 1 - modules/nixvim/meta.nix | 61 ------------- modules/nixvim/nixos.nix | 1 - modules/nvf/darwin.nix | 1 - modules/nvf/hm.nix | 1 - modules/nvf/meta.nix | 31 ------- modules/nvf/nixos.nix | 1 - modules/vim/meta.nix | 20 ----- 23 files changed, 184 insertions(+), 216 deletions(-) delete mode 100644 modules/neovide/meta.nix create mode 100644 modules/neovim/darwin.nix rename modules/{neovide/nixvim.nix => neovim/neovide-common.nix} (100%) rename modules/{neovide/hm.nix => neovim/neovide.nix} (96%) create mode 100644 modules/neovim/neovim.nix create mode 100644 modules/neovim/nixos.nix rename modules/{nixvim => neovim}/nixvim.nix (98%) rename modules/{nvf => neovim}/nvf.nix (100%) rename modules/{neovide => neovim}/testbeds/neovide.nix (100%) rename modules/{vim/hm.nix => neovim/vim.nix} (99%) delete mode 100644 modules/nixvim/darwin.nix delete mode 100644 modules/nixvim/hm.nix delete mode 100644 modules/nixvim/meta.nix delete mode 100644 modules/nixvim/nixos.nix delete mode 100644 modules/nvf/darwin.nix delete mode 100644 modules/nvf/hm.nix delete mode 100644 modules/nvf/meta.nix delete mode 100644 modules/nvf/nixos.nix delete mode 100644 modules/vim/meta.nix diff --git a/doc/book.toml b/doc/book.toml index 8c830c87..841b51e2 100644 --- a/doc/book.toml +++ b/doc/book.toml @@ -29,3 +29,6 @@ enable = true [output.html.redirect] "/options/hm.html" = "./platforms/home_manager.html" "/options/nixos.html" = "./platforms/nixos.html" +"/options/modules/nixvim.html" = "./neovim.html" +"/options/modules/nvf.html" = "./neovim.html" +"/options/modules/vim.html" = "./neovim.html" diff --git a/doc/redirects.js b/doc/redirects.js index 7f2ca9a0..c5d7ca0b 100644 --- a/doc/redirects.js +++ b/doc/redirects.js @@ -3,7 +3,7 @@ // NOTE: This script doesn't run on 404.html, so the old page must still exist. const redirects = { "/configuration.html#standalone-nixvim": - "./options/modules/nixvim.html#standalone-mode", + "./options/modules/neovim.html#standalone-mode", }; const fullPath = window.location.pathname + window.location.hash; diff --git a/modules/neovide/meta.nix b/modules/neovide/meta.nix deleted file mode 100644 index 850f05e7..00000000 --- a/modules/neovide/meta.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ lib, ... }: -{ - name = "Neovide"; - homepage = "https://neovide.dev/"; - maintainers = [ lib.maintainers.mightyiam ]; -} diff --git a/modules/neovim/darwin.nix b/modules/neovim/darwin.nix new file mode 100644 index 00000000..40b8a15b --- /dev/null +++ b/modules/neovim/darwin.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./nvf.nix + ./nixvim.nix + ]; +} diff --git a/modules/neovim/hm.nix b/modules/neovim/hm.nix index 64d9698c..2b1e5380 100644 --- a/modules/neovim/hm.nix +++ b/modules/neovim/hm.nix @@ -1,81 +1,10 @@ +{ mkTarget, lib, ... }: { - pkgs, - config, - lib, - ... -}: -{ - options.stylix.targets.neovim = { - enable = config.lib.stylix.mkEnableTarget "Neovim" true; - plugin = lib.mkOption { - type = lib.types.enum [ - "base16-nvim" - "mini.base16" - ]; - default = "mini.base16"; - description = "Plugin used for the colorscheme"; - }; - transparentBackground = { - main = lib.mkEnableOption "background transparency for the main Neovim window"; - signColumn = lib.mkEnableOption "background transparency for the Neovim sign column"; - numberLine = lib.mkEnableOption "background transparency for the NeoVim number/relativenumber column"; - }; - }; - - config = - lib.mkIf (config.stylix.enable && config.stylix.targets.neovim.enable) - { - programs.neovim = - let - cfg = config.stylix.targets.neovim; - transparencyCfg = builtins.toString ( - lib.optional cfg.transparentBackground.main '' - vim.cmd.highlight({ "Normal", "guibg=NONE", "ctermbg=NONE" }) - vim.cmd.highlight({ "NonText", "guibg=NONE", "ctermbg=NONE" }) - '' - ++ lib.optional cfg.transparentBackground.signColumn '' - vim.cmd.highlight({ "SignColumn", "guibg=NONE", "ctermbg=NONE" }) - '' - ++ lib.optional cfg.transparentBackground.numberLine '' - vim.cmd.highlight({ "LineNr", "guibg=NONE", "ctermbg=NONE" }) - vim.cmd.highlight({ "LineNrAbove", "guibg=NONE", "ctermbg=NONE" }) - vim.cmd.highlight({ "LineNrBelow", "guibg=NONE", "ctermbg=NONE" }) - '' - ); - in - { - plugins = [ - (lib.mkIf (cfg.plugin == "base16-nvim") { - plugin = pkgs.vimPlugins.base16-nvim; - type = "lua"; - config = with config.lib.stylix.colors.withHashtag; '' - require('base16-colorscheme').setup({ - base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}', - base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}', - base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}', - base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}' - }) - - ${transparencyCfg} - ''; - }) - (lib.mkIf (cfg.plugin == "mini.base16") { - plugin = pkgs.vimPlugins.mini-nvim; - type = "lua"; - config = with config.lib.stylix.colors.withHashtag; '' - require('mini.base16').setup({ - palette = { - base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}', - base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}', - base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}', - base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}' - } - }) - - ${transparencyCfg} - ''; - }) - ]; - }; - }; + imports = [ + ./neovim.nix + (lib.modules.importApply ./neovide.nix mkTarget) + ./nixvim.nix + ./nvf.nix + (lib.modules.importApply ./vim.nix mkTarget) + ]; } diff --git a/modules/neovim/meta.nix b/modules/neovim/meta.nix index 4d839aea..ef53920c 100644 --- a/modules/neovim/meta.nix +++ b/modules/neovim/meta.nix @@ -1,20 +1,87 @@ +{ lib, ... }: { - name = "Neovim"; - homepage = "https://www.neovim.io/"; - maintainers = [ ]; + name = "Neovim, Neovide, NixVim, nvf, and Vim"; + homepage = { + Neovim = "https://www.neovim.io/"; + Neovide = "https://neovide.dev/"; + NixVim = "https://github.com/nix-community/nixvim"; + nvf = "https://github.com/NotAShelf/nvf"; + Vim = "http://www.vim.org/"; + }; + maintainers = with lib.maintainers; [ + butzist + mightyiam + naho + ]; description = '' - This module themes [Neovim] using the standard Home Manager options. + ### Neovim - ### Related modules + This target themes [Neovim] using the standard Home Manager options. - + ### NixVim - - [Vim](vim.md): themes Vim using the standard Home Manager options. - - [Nixvim](nixvim.md): themes Neovim using the options provided by [Nixvim]. - - [nvf](nvf.md): themes Neovim using the options provided by [nvf]. + This target themes [Neovim] using the options provided by [NixVim]. + + > [!IMPORTANT] + > This target will have no effect unless the desired Nixvim module is properly + > [installed](https://github.com/nix-community/nixvim?tab=readme-ov-file#installation) + > and + > [imported](https://github.com/nix-community/nixvim?tab=readme-ov-file#usage) + > into your configuration. + > + > Ensure you are configuring this target on the same platform (NixOS, Home + > Manager, Darwin) as where you installed Nixvim. + + #### Standalone Mode + + When using a NixOS or home-manager installation of [NixVim], you can use Stylix + as normal. However, when using Nixvim's ["standalone" configuration mode][NixVim Standalone], + you will need to pass Stylix's generated config to Nixvim yourself. + + The generated config can be accessed as `config.lib.stylix.nixvim.config`. You + can use this as a module in your standalone Nixvim Configuration or an + extension of it. + + For example: + + ```nix + { + inputs, + config, + pkgs, + ... + }: + let + inherit (pkgs.stdenv.hostPlatform) system; + nixvim-package = inputs.nixvim-config.packages.''${system}.default; + extended-nixvim = nixvim-package.extend config.lib.stylix.nixvim.config; + in + { + environment.systemPackages = [ extended-nixvim ]; + } + ``` + + ### nvf + + This target themes [Neovim] using the options provided by [nvf]. + + > [!IMPORTANT] + > This target will have no effect unless the desired nvf module is properly + > [installed](https://notashelf.github.io/nvf/index.xhtml#ch-installation) + > and + > [imported](https://notashelf.github.io/nvf/index.xhtml#ch-module-installation) + > into your configuration. + > + > Ensure you are configuring this target on the same platform (NixOS, Home + > Manager, Darwin) as where you installed nvf. + + ### Vim + + This target themes [Vim] using the standard Home Manager options. [Neovim]: https://neovim.io [Nixvim]: https://github.com/nix-community/nixvim#readme [nvf]: https://github.com/NotAShelf/nvf#readme + [Vim]: https://www.vim.org ''; } diff --git a/modules/neovide/nixvim.nix b/modules/neovim/neovide-common.nix similarity index 100% rename from modules/neovide/nixvim.nix rename to modules/neovim/neovide-common.nix diff --git a/modules/neovide/hm.nix b/modules/neovim/neovide.nix similarity index 96% rename from modules/neovide/hm.nix rename to modules/neovim/neovide.nix index a69345bc..ed38e3a6 100644 --- a/modules/neovide/hm.nix +++ b/modules/neovim/neovide.nix @@ -1,4 +1,4 @@ -{ mkTarget, ... }: +mkTarget: mkTarget { name = "neovide"; humanName = "Neovide"; diff --git a/modules/neovim/neovim.nix b/modules/neovim/neovim.nix new file mode 100644 index 00000000..23a74a93 --- /dev/null +++ b/modules/neovim/neovim.nix @@ -0,0 +1,81 @@ +{ + config, + lib, + pkgs, + ... +}: +{ + options.stylix.targets.neovim = { + enable = config.lib.stylix.mkEnableTarget "Neovim" true; + plugin = lib.mkOption { + type = lib.types.enum [ + "base16-nvim" + "mini.base16" + ]; + default = "mini.base16"; + description = "Plugin used for the colorscheme"; + }; + transparentBackground = { + main = lib.mkEnableOption "background transparency for the main Neovim window"; + signColumn = lib.mkEnableOption "background transparency for the Neovim sign column"; + numberLine = lib.mkEnableOption "background transparency for the NeoVim number/relativenumber column"; + }; + }; + + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.neovim.enable) + { + programs.neovim = + let + cfg = config.stylix.targets.neovim; + transparencyCfg = builtins.toString ( + lib.optional cfg.transparentBackground.main '' + vim.cmd.highlight({ "Normal", "guibg=NONE", "ctermbg=NONE" }) + vim.cmd.highlight({ "NonText", "guibg=NONE", "ctermbg=NONE" }) + '' + ++ lib.optional cfg.transparentBackground.signColumn '' + vim.cmd.highlight({ "SignColumn", "guibg=NONE", "ctermbg=NONE" }) + '' + ++ lib.optional cfg.transparentBackground.numberLine '' + vim.cmd.highlight({ "LineNr", "guibg=NONE", "ctermbg=NONE" }) + vim.cmd.highlight({ "LineNrAbove", "guibg=NONE", "ctermbg=NONE" }) + vim.cmd.highlight({ "LineNrBelow", "guibg=NONE", "ctermbg=NONE" }) + '' + ); + in + { + plugins = [ + (lib.mkIf (cfg.plugin == "base16-nvim") { + plugin = pkgs.vimPlugins.base16-nvim; + type = "lua"; + config = with config.lib.stylix.colors.withHashtag; '' + require('base16-colorscheme').setup({ + base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}', + base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}', + base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}', + base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}' + }) + + ${transparencyCfg} + ''; + }) + (lib.mkIf (cfg.plugin == "mini.base16") { + plugin = pkgs.vimPlugins.mini-nvim; + type = "lua"; + config = with config.lib.stylix.colors.withHashtag; '' + require('mini.base16').setup({ + palette = { + base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}', + base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}', + base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}', + base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}' + } + }) + + ${transparencyCfg} + ''; + }) + ]; + }; + }; +} diff --git a/modules/neovim/nixos.nix b/modules/neovim/nixos.nix new file mode 100644 index 00000000..40b8a15b --- /dev/null +++ b/modules/neovim/nixos.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./nvf.nix + ./nixvim.nix + ]; +} diff --git a/modules/nixvim/nixvim.nix b/modules/neovim/nixvim.nix similarity index 98% rename from modules/nixvim/nixvim.nix rename to modules/neovim/nixvim.nix index c93bf317..6093078d 100644 --- a/modules/nixvim/nixvim.nix +++ b/modules/neovim/nixvim.nix @@ -137,7 +137,7 @@ in { lib.stylix.nixvim.config = { imports = [ - (lib.modules.importApply ../neovide/nixvim.nix config.stylix) + (lib.modules.importApply ./neovide-common.nix config.stylix) ]; config = lib.mkMerge [ pluginConfigs.${cfg.plugin} diff --git a/modules/nvf/nvf.nix b/modules/neovim/nvf.nix similarity index 100% rename from modules/nvf/nvf.nix rename to modules/neovim/nvf.nix diff --git a/modules/neovide/testbeds/neovide.nix b/modules/neovim/testbeds/neovide.nix similarity index 100% rename from modules/neovide/testbeds/neovide.nix rename to modules/neovim/testbeds/neovide.nix diff --git a/modules/vim/hm.nix b/modules/neovim/vim.nix similarity index 99% rename from modules/vim/hm.nix rename to modules/neovim/vim.nix index 939a7c8d..11b3bac5 100644 --- a/modules/vim/hm.nix +++ b/modules/neovim/vim.nix @@ -1,5 +1,5 @@ +mkTarget: { - mkTarget, lib, pkgs, ... diff --git a/modules/nixvim/darwin.nix b/modules/nixvim/darwin.nix deleted file mode 100644 index 3bcbdf8e..00000000 --- a/modules/nixvim/darwin.nix +++ /dev/null @@ -1 +0,0 @@ -import ./nixvim.nix diff --git a/modules/nixvim/hm.nix b/modules/nixvim/hm.nix deleted file mode 100644 index 3bcbdf8e..00000000 --- a/modules/nixvim/hm.nix +++ /dev/null @@ -1 +0,0 @@ -import ./nixvim.nix diff --git a/modules/nixvim/meta.nix b/modules/nixvim/meta.nix deleted file mode 100644 index 7dfdfa45..00000000 --- a/modules/nixvim/meta.nix +++ /dev/null @@ -1,61 +0,0 @@ -{ lib, ... }: -{ - name = "NixVim"; - homepage = "https://github.com/nix-community/nixvim"; - maintainers = [ lib.maintainers.naho ]; - description = '' - This module themes [Neovim] using the options provided by [NixVim]. - - > [!IMPORTANT] - > This module will have no effect unless the desired Nixvim module is properly - > [installed](https://github.com/nix-community/nixvim?tab=readme-ov-file#installation) - > and - > [imported](https://github.com/nix-community/nixvim?tab=readme-ov-file#usage) - > into your configuration. - > - > Ensure you are configuring this module on the same platform (NixOS, Home - > Manager, Darwin) as where you installed Nixvim. - - ### Standalone Mode - - When using a NixOS or home-manager installation of [NixVim], you can use Stylix - as normal. However, when using Nixvim's ["standalone" configuration mode][NixVim Standalone], - you will need to pass Stylix's generated config to Nixvim yourself. - - The generated config can be accessed as `config.lib.stylix.nixvim.config`. You - can use this as a module in your standalone Nixvim Configuration or an - extension of it. - - For example: - - ```nix - { - inputs, - config, - pkgs, - ... - }: - let - inherit (pkgs.stdenv.hostPlatform) system; - nixvim-package = inputs.nixvim-config.packages.''${system}.default; - extended-nixvim = nixvim-package.extend config.lib.stylix.nixvim.config; - in - { - environment.systemPackages = [ extended-nixvim ]; - } - ``` - - ### Related modules - - - - - [Vim](vim.md): themes Vim using the standard Home Manager options. - - [Neovim](neovim.md): themes Neovim using the standard Home Manager options. - - [nvf](nvf.md): themes Neovim using the options provided by [nvf]. - - [Neovim]: https://neovim.io - [NixVim]: https://github.com/nix-community/nixvim#readme - [NixVim Standalone]: https://nix-community.github.io/nixvim/user-guide/install.html#standalone-usage - [nvf]: https://github.com/NotAShelf/nvf#readme - ''; -} diff --git a/modules/nixvim/nixos.nix b/modules/nixvim/nixos.nix deleted file mode 100644 index 3bcbdf8e..00000000 --- a/modules/nixvim/nixos.nix +++ /dev/null @@ -1 +0,0 @@ -import ./nixvim.nix diff --git a/modules/nvf/darwin.nix b/modules/nvf/darwin.nix deleted file mode 100644 index 458d0464..00000000 --- a/modules/nvf/darwin.nix +++ /dev/null @@ -1 +0,0 @@ -import ./nvf.nix diff --git a/modules/nvf/hm.nix b/modules/nvf/hm.nix deleted file mode 100644 index 458d0464..00000000 --- a/modules/nvf/hm.nix +++ /dev/null @@ -1 +0,0 @@ -import ./nvf.nix diff --git a/modules/nvf/meta.nix b/modules/nvf/meta.nix deleted file mode 100644 index 4622378f..00000000 --- a/modules/nvf/meta.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ lib, ... }: -{ - name = "nvf"; - homepage = "https://github.com/NotAShelf/nvf"; - maintainers = [ lib.maintainers.butzist ]; - description = '' - This module themes [Neovim] using the options provided by [nvf]. - - > [!IMPORTANT] - > This module will have no effect unless the desired nvf module is properly - > [installed](https://notashelf.github.io/nvf/index.xhtml#ch-installation) - > and - > [imported](https://notashelf.github.io/nvf/index.xhtml#ch-module-installation) - > into your configuration. - > - > Ensure you are configuring this module on the same platform (NixOS, Home - > Manager, Darwin) as where you installed nvf. - - ### Related modules - - - - - [Vim](vim.md): themes Vim using the standard Home Manager options. - - [Neovim](neovim.md): themes Neovim using the standard Home Manager options. - - [Nixvim](nixvim.md): themes Neovim using the options provided by [Nixvim]. - - [Neovim]: https://neovim.io - [Nixvim]: https://github.com/nix-community/nixvim#readme - [nvf]: https://github.com/NotAShelf/nvf#readme - ''; -} diff --git a/modules/nvf/nixos.nix b/modules/nvf/nixos.nix deleted file mode 100644 index 458d0464..00000000 --- a/modules/nvf/nixos.nix +++ /dev/null @@ -1 +0,0 @@ -import ./nvf.nix diff --git a/modules/vim/meta.nix b/modules/vim/meta.nix deleted file mode 100644 index 65bf7cff..00000000 --- a/modules/vim/meta.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ - name = "Vim"; - homepage = "http://www.vim.org/"; - maintainers = [ ]; - description = '' - This module themes [Vim] using the standard Home Manager options. - - ### Related modules - - - - - [Neovim](neovim.md): themes Neovim using the standard Home Manager options. - - [Nixvim](nixvim.md): themes Neovim using the options provided by [Nixvim]. - - [nvf](nvf.md): themes Neovim using the options provided by [nvf]. - - [Vim]: https://www.vim.org - [Nixvim]: https://github.com/nix-community/nixvim#readme - [nvf]: https://github.com/NotAShelf/nvf#readme - ''; -}