Skip to content

Commit

Permalink
neovim: add plugin selection option
Browse files Browse the repository at this point in the history
Add an option to select whether to use 'mini.base16' or 'base16-nvim'.

Link: danth#536
  • Loading branch information
soulsoiledit committed Aug 29, 2024
1 parent d587901 commit 9305cc7
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 19 deletions.
16 changes: 14 additions & 2 deletions modules/neovim/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
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 = "Which plugin to use for the colorscheme";
};
transparentBackground = {
main = lib.mkEnableOption "background transparency for the main Neovim window";
signColumn = lib.mkEnableOption "background transparency for the Neovim sign column";
Expand All @@ -21,7 +25,15 @@
plugin = pkgs.vimPlugins.mini-nvim;
type = "lua";
config = lib.mkMerge [
(with config.lib.stylix.colors.withHashtag; ''
(with config.lib.stylix.colors.withHashtag; lib.mkIf (cfg.plugin == "base16-nvim") ''
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}'
})
'')
(with config.lib.stylix.colors.withHashtag; lib.mkIf (cfg.plugin == "mini.base16") ''
require('mini.base16').setup({
palette = {
base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}',
Expand Down
55 changes: 38 additions & 17 deletions modules/nixvim/nixvim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
lib,
options,
...
}: {
}:
let
cfg = config.stylix.targets.nixvim;
in {
options.stylix.targets.nixvim = {
enable =
config.lib.stylix.mkEnableTarget "nixvim" true;
plugin = lib.mkOption {
type = lib.types.enum [ "base16-nvim" "mini.base16" ];
default = "mini.base16";
description = "Which plugin to use for the colorscheme";
};
transparentBackground = {
main = lib.mkEnableOption "background transparency for the main NeoVim window";
signColumn = lib.mkEnableOption "background transparency for the NeoVim sign column";
Expand All @@ -25,31 +33,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 = {
plugins.mini = {
config = lib.mkIf (config.stylix.enable && cfg.enable && (config.programs ? nixvim)) (
lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) (lib.mkMerge [
(lib.mkIf (cfg.plugin == "base16-nvim") {
programs.nixvim.colorschemes.base16 = {
enable = true;

modules.base16.palette = {
colorscheme = {
inherit (config.lib.stylix.colors.withHashtag)
base00 base01 base02 base03 base04 base05 base06 base07
base08 base09 base0A base0B base0C base0D base0E base0F;
};
};
})
(lib.mkIf (cfg.plugin == "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 9305cc7

Please sign in to comment.