Skip to content

Commit

Permalink
Adds support for styling nixvim (#194)
Browse files Browse the repository at this point in the history
Closes #153

Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Co-authored-by: Daniel Thwaites <danthwaites30@btinternet.com>
  • Loading branch information
3 people authored Dec 19, 2023
1 parent 41d2185 commit d14ac49
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/nixvim/darwin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import ./nixvim.nix
1 change: 1 addition & 0 deletions modules/nixvim/hm.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import ./nixvim.nix
1 change: 1 addition & 0 deletions modules/nixvim/nixos.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import ./nixvim.nix
58 changes: 58 additions & 0 deletions modules/nixvim/nixvim.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
config,
lib,
options,
...
}: {
options.stylix.targets.nixvim = {
enable =
config.lib.stylix.mkEnableTarget "nixvim" (config.programs ? nixvim);
transparent_bg = {
main = lib.mkEnableOption "background transparency for the main NeoVim window";
sign_column = lib.mkEnableOption "background transparency for the NeoVim sign column";
};
};

config = lib.mkIf ((config.programs ? nixvim) && config.stylix.targets.nixvim.enable) (
lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) {
programs.nixvim = {
colorschemes.base16 = {
customColorScheme = let
colors = config.lib.stylix.colors.withHashtag;
in {
base00 = colors.base00;
base01 = colors.base01;
base02 = colors.base02;
base03 = colors.base03;
base04 = colors.base04;
base05 = colors.base05;
base06 = colors.base06;
base07 = colors.base07;
base08 = colors.base08;
base09 = colors.base09;
base0A = colors.base0A;
base0B = colors.base0B;
base0C = colors.base0C;
base0D = colors.base0D;
base0E = colors.base0E;
base0F = colors.base0F;
};

enable = true;
};

highlight = let
cfg = config.stylix.targets.nixvim;
transparent = {
bg = "none";
ctermbg = "none";
};
in {
Normal = lib.mkIf cfg.transparent_bg.main transparent;
NonText = lib.mkIf cfg.transparent_bg.main transparent;
SignColumn = lib.mkIf cfg.transparent_bg.sign_column transparent;
};
};
}
);
}

0 comments on commit d14ac49

Please sign in to comment.