Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dark and light theme support #442

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions modules/global.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
Comment on lines +29 to +39
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too big a fan of this API. I think it'd be better to have a single enum option defining whether or not to use dark mode, and continuing using the local flavor option in modules (which should be fine since both can still be overridden on a per-module basis if you'd like light mode with a different-than-global flavor for example)

i.e., this would become

{
  # Or maybe name it `mode`? I dunno
  theme = lib.mkOption {
    type = lib.types.oneOf [ "light" "dark" ];
    default = dark;
    description = "Global Catppuccin theme type";
    example = lib.literalExpression "light";
  };
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the idea, but i assume some people like macOS users would be more wanting to have the dark and light options since they are not enforced into declarative light/dark.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and totally forgot for ghostty which is a single string, making it a bit hard to do that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too sure how else to generalize this API then. Having dynamic light/dark is virtually exclusive to macOS, and most apps will just not support it; I don't know where else this would really be used besides Ghostty and Zed

If we can configure either of those two to use a "dynamic" mode, I would be fine with that being a third option in this enum -- and those two ports having their own exclusive light/darkFlavor options. Otherwise I don't think this is a good fit here


accent = lib.mkOption {
type = catppuccinLib.types.accent;
default = "mauve";
Expand Down
17 changes: 11 additions & 6 deletions modules/home-manager/zed-editor.nix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then we would configure zed to use the light or dark theme

...assuming that's possible. I'd really like it to be since I feel like making the light/dark theme choice imperative is a bit odd and unlike what we do with flavors, accents, and enabling the themes themselves

Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -19,11 +24,11 @@ in
userSettings.theme = {
light =
"Catppuccin "
+ catppuccinLib.mkUpper cfg.flavor
+ catppuccinLib.mkUpper cfg.lightFlavor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would stay the same

Suggested change
+ catppuccinLib.mkUpper cfg.lightFlavor
+ catppuccinLib.mkUpper cfg.flavor

+ lib.optionalString (!cfg.italics) " - No Italics";
dark =
"Catppuccin "
+ catppuccinLib.mkUpper cfg.flavor
+ catppuccinLib.mkUpper cfg.darkFlavor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

+ lib.optionalString (!cfg.italics) " - No Italics";
};
};
Expand Down
14 changes: 14 additions & 0 deletions modules/lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}:

{
Expand All @@ -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}";
};
};

/**
Expand Down
Loading