From 88c94091b928a7ca649ace9bb68ec18224162c61 Mon Sep 17 00:00:00 2001 From: isabel Date: Tue, 31 Dec 2024 08:28:20 +0000 Subject: [PATCH] feat: dark and light theme support --- modules/global.nix | 12 ++++++++++++ modules/home-manager/zed-editor.nix | 17 +++++++++++------ modules/lib/default.nix | 14 ++++++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/modules/global.nix b/modules/global.nix index 68a0c4d4..ab014816 100644 --- a/modules/global.nix +++ b/modules/global.nix @@ -26,6 +26,18 @@ in description = "Global Catppuccin flavor"; }; + darkFlavor = lib.mkOption { + type = catppuccinLib.types.flavor; + default = config.catppuccin.flavor; + description = "Global Catppuccin dark flavor"; + }; + + lightFlavor = lib.mkOption { + type = catppuccinLib.types.flavor; + default = config.catppuccin.flavor; + description = "Global Catppuccin light flavor"; + }; + accent = lib.mkOption { type = catppuccinLib.types.accent; default = "mauve"; diff --git a/modules/home-manager/zed-editor.nix b/modules/home-manager/zed-editor.nix index a79920b6..66e8368a 100644 --- a/modules/home-manager/zed-editor.nix +++ b/modules/home-manager/zed-editor.nix @@ -6,11 +6,16 @@ let in { - options.catppuccin.zed = catppuccinLib.mkCatppuccinOption { name = "zed"; } // { - italics = lib.mkEnableOption "the italicized version of theme" // { - default = true; + options.catppuccin.zed = + catppuccinLib.mkCatppuccinOption { + name = "zed"; + darkLightSupport = true; + } + // { + italics = lib.mkEnableOption "the italicized version of theme" // { + default = true; + }; }; - }; config = lib.mkIf cfg.enable { programs.zed-editor = { @@ -19,11 +24,11 @@ in userSettings.theme = { light = "Catppuccin " - + catppuccinLib.mkUpper cfg.flavor + + catppuccinLib.mkUpper cfg.lightFlavor + lib.optionalString (!cfg.italics) " - No Italics"; dark = "Catppuccin " - + catppuccinLib.mkUpper cfg.flavor + + catppuccinLib.mkUpper cfg.darkFlavor + lib.optionalString (!cfg.italics) " - No Italics"; }; }; diff --git a/modules/lib/default.nix b/modules/lib/default.nix index 84249be3..10c477f6 100644 --- a/modules/lib/default.nix +++ b/modules/lib/default.nix @@ -189,6 +189,7 @@ lib.makeExtensible (ctp: { default ? if useGlobalEnable then config.catppuccin.enable else false, defaultText ? if useGlobalEnable then "catppuccin.enable" else null, accentSupport ? false, + darkLightSupport ? false, }: { @@ -213,6 +214,19 @@ lib.makeExtensible (ctp: { default = config.catppuccin.accent; description = "Catppuccin accent for ${name}"; }; + } + // optionalAttrs darkLightSupport { + darkFlavor = mkOption { + type = ctp.types.flavor; + default = config.catppuccin.darkFlavor; + description = "Catppuccin dark flavor for ${name}"; + }; + + lightFlavor = mkOption { + type = ctp.types.flavor; + default = config.catppuccin.lightFlavor; + description = "Catppuccin light flavor for ${name}"; + }; }; /**