Skip to content

Commit

Permalink
nixvim: add stylix.targets.nixvim.colorscheme option
Browse files Browse the repository at this point in the history
Add the stylix.targets.nixvim.colorscheme option to select between the
previous base16-nvim and the new default mini.base16 [1] plugin,
offering better plugin integration.

[1]: https://github.com/echasnovski/mini.base16

Link: danth#536

Co-authored-by: NAHO <[email protected]>
Tested-by: NAHO <[email protected]>
  • Loading branch information
soulsoiledit and trueNAHO committed Sep 19, 2024
1 parent 8265d60 commit 9c1755d
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions modules/nixvim/nixvim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
lib,
options,
...
}: {
}: let
cfg = config.stylix.targets.nixvim;
in {
options.stylix.targets.nixvim = {
colorscheme = lib.mkOption {
type = lib.types.enum [ "base16-nvim" "mini.base16" ];
default = "mini.base16";
description = "Strategy for applying the colorscheme";
};
enable =
config.lib.stylix.mkEnableTarget "nixvim" true;
transparentBackground = {
Expand All @@ -25,31 +32,44 @@
[ "stylix" "targets" "nixvim" "transparentBackground" "signColumn" ])
];

config = lib.mkIf (config.stylix.enable && config.stylix.targets.nixvim.enable && (config.programs ? nixvim)) (
lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) {
programs.nixvim = {
colorschemes.base16 = {
config = lib.mkIf (config.stylix.enable && cfg.enable && (config.programs ? nixvim)) (
lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) (lib.mkMerge [
(lib.mkIf (cfg.colorscheme == "base16-nvim") {
programs.nixvim.colorschemes.base16 = {
enable = true;

colorscheme = {
inherit (config.lib.stylix.colors.withHashtag)
base00 base01 base02 base03 base04 base05 base06 base07
base08 base09 base0A base0B base0C base0D base0E base0F;
};

enable = true;
};
})
(lib.mkIf (cfg.colorscheme == "mini.base16") {
programs.nixvim.plugins.mini = {
enable = true;

highlight = let
cfg = config.stylix.targets.nixvim;
transparent = {
bg = "none";
ctermbg = "none";
modules.base16.palette = {
inherit (config.lib.stylix.colors.withHashtag)
base00 base01 base02 base03 base04 base05 base06 base07
base08 base09 base0A base0B base0C base0D base0E base0F;
};
};
})
{
programs.nixvim = {
highlight = let
transparent = {
bg = "none";
ctermbg = "none";
};
in {
Normal = lib.mkIf cfg.transparentBackground.main transparent;
NonText = lib.mkIf cfg.transparentBackground.main transparent;
SignColumn = lib.mkIf cfg.transparentBackground.signColumn transparent;
};
in {
Normal = lib.mkIf cfg.transparentBackground.main transparent;
NonText = lib.mkIf cfg.transparentBackground.main transparent;
SignColumn = lib.mkIf cfg.transparentBackground.signColumn transparent;
};
};
}
}
])
);
}

0 comments on commit 9c1755d

Please sign in to comment.