From d14ac4912a9ab02f8b49b761e9e4b9ae836171af Mon Sep 17 00:00:00 2001 From: willemml Date: Tue, 19 Dec 2023 08:40:37 -0800 Subject: [PATCH] Adds support for styling nixvim (#194) Closes #153 Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com> Co-authored-by: Daniel Thwaites --- modules/nixvim/darwin.nix | 1 + modules/nixvim/hm.nix | 1 + modules/nixvim/nixos.nix | 1 + modules/nixvim/nixvim.nix | 58 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 modules/nixvim/darwin.nix create mode 100644 modules/nixvim/hm.nix create mode 100644 modules/nixvim/nixos.nix create mode 100644 modules/nixvim/nixvim.nix diff --git a/modules/nixvim/darwin.nix b/modules/nixvim/darwin.nix new file mode 100644 index 0000000..3bcbdf8 --- /dev/null +++ b/modules/nixvim/darwin.nix @@ -0,0 +1 @@ +import ./nixvim.nix diff --git a/modules/nixvim/hm.nix b/modules/nixvim/hm.nix new file mode 100644 index 0000000..3bcbdf8 --- /dev/null +++ b/modules/nixvim/hm.nix @@ -0,0 +1 @@ +import ./nixvim.nix diff --git a/modules/nixvim/nixos.nix b/modules/nixvim/nixos.nix new file mode 100644 index 0000000..3bcbdf8 --- /dev/null +++ b/modules/nixvim/nixos.nix @@ -0,0 +1 @@ +import ./nixvim.nix diff --git a/modules/nixvim/nixvim.nix b/modules/nixvim/nixvim.nix new file mode 100644 index 0000000..4802765 --- /dev/null +++ b/modules/nixvim/nixvim.nix @@ -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; + }; + }; + } + ); +}