Skip to content

Commit

Permalink
feat: apply new ANSI terminal colours (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoudham authored Nov 6, 2024
1 parent 2987e0f commit 034def5
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 29 deletions.
2 changes: 1 addition & 1 deletion nix/yarn-project.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let
rm $out/.gitignore
'';
outputHashMode = "recursive";
outputHash = "sha512-hoLzOaE5fvtkoVutJNQ6o/3sQB2sBuPU3H1knHiLHh6qJniJK1r0nf7qOhePsuqzZgSbAdguot2N8VD+2oRB9A==";
outputHash = "sha512-ciFAqqoMV8Eb7PH6gZWTMBDHnWgBTYCqhgSsk6i7AmP0923iIOyXqGjU6yve7hdhQWOisMYYO47EoJePxpXHRw==";
};

# Main project derivation.
Expand Down
2 changes: 1 addition & 1 deletion packages/catppuccin-vsc-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"license": "MIT",
"private": true,
"devDependencies": {
"@catppuccin/palette": "^1.1.1",
"@catppuccin/palette": "^1.7.1",
"@fontsource/jetbrains-mono": "^5.0.20",
"@storybook/addon-essentials": "^8.0.9",
"@storybook/addon-styling": "^1.3.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/catppuccin-vsc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
},
"devDependencies": {
"@actions/core": "^1.10.1",
"@catppuccin/palette": "^1.1.1",
"@catppuccin/palette": "^1.7.1",
"@catppuccin/vsc-typegen": "workspace:*",
"@tsconfig/node18": "^18.2.4",
"@types/node": "^20.12.7",
Expand Down
10 changes: 10 additions & 0 deletions packages/catppuccin-vsc/src/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { flavors } from "@catppuccin/palette";

import type {
CatppuccinPaletteAnsi,
CatppuccinFlavor,
CatppuccinPalette,
ThemeContext,
Expand Down Expand Up @@ -29,9 +30,17 @@ export const compileTheme = (
) => {
const flavorData = flavors[flavor];
const ctpPalette = {} as CatppuccinPalette;
const paletteAnsi = {
normal: {},
bright: {},
} as CatppuccinPaletteAnsi;
for (const [k, v] of flavorData.colorEntries) {
ctpPalette[k] = v.hex;
}
for (const [k, v] of flavorData.ansiColorEntries) {
paletteAnsi.normal[k] = v.normal.hex;
paletteAnsi.bright[k] = v.bright.hex;
}

const palette: CatppuccinPalette = {
...ctpPalette,
Expand All @@ -42,6 +51,7 @@ export const compileTheme = (
const context: ThemeContext = {
flavor,
palette,
paletteAnsi,
options,
isLatte: flavor === "latte",
};
Expand Down
34 changes: 17 additions & 17 deletions packages/catppuccin-vsc/src/theme/uiColors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import uiCustomizations from "./ui";
export const getUiColors = (
context: ThemeContext,
): Partial<Record<keyof WorkbenchColors, string>> => {
const { palette, options, isLatte } = context;
const { palette, paletteAnsi, options, isLatte } = context;

const accent = palette[options.accent];
const dropBackground = opacity(accent, 0.2);
Expand Down Expand Up @@ -437,22 +437,22 @@ export const getUiColors = (

// Terminal
"terminal.foreground": palette.text,
"terminal.ansiBlack": isLatte ? palette.surface1 : palette.subtext0, // color0
"terminal.ansiRed": palette.red, // color1
"terminal.ansiGreen": palette.green, // color2
"terminal.ansiYellow": palette.yellow, // color3
"terminal.ansiBlue": palette.blue, // color4
"terminal.ansiMagenta": palette.pink, // color5
"terminal.ansiCyan": palette.sky, // color6
"terminal.ansiWhite": isLatte ? palette.surface2 : palette.subtext1, // color7
"terminal.ansiBrightBlack": isLatte ? palette.subtext0 : palette.surface2, // color8
"terminal.ansiBrightRed": palette.red, // color9
"terminal.ansiBrightGreen": palette.green, // color10
"terminal.ansiBrightYellow": palette.yellow, // color11
"terminal.ansiBrightBlue": palette.blue, // color12
"terminal.ansiBrightMagenta": palette.pink, // color13
"terminal.ansiBrightCyan": palette.sky, // color14
"terminal.ansiBrightWhite": isLatte ? palette.subtext1 : palette.surface1, // color15
"terminal.ansiBlack": paletteAnsi.normal.black, // color0
"terminal.ansiRed": paletteAnsi.normal.red, // color1
"terminal.ansiGreen": paletteAnsi.normal.green, // color2
"terminal.ansiYellow": paletteAnsi.normal.yellow, // color3
"terminal.ansiBlue": paletteAnsi.normal.blue, // color4
"terminal.ansiMagenta": paletteAnsi.normal.magenta, // color5
"terminal.ansiCyan": paletteAnsi.normal.cyan, // color6
"terminal.ansiWhite": paletteAnsi.normal.white, // color7
"terminal.ansiBrightBlack": paletteAnsi.bright.black, // color8
"terminal.ansiBrightRed": paletteAnsi.bright.red, // color9
"terminal.ansiBrightGreen": paletteAnsi.bright.green, // color10
"terminal.ansiBrightYellow": paletteAnsi.bright.yellow, // color11
"terminal.ansiBrightBlue": paletteAnsi.bright.blue, // color12
"terminal.ansiBrightMagenta": paletteAnsi.bright.magenta, // color13
"terminal.ansiBrightCyan": paletteAnsi.bright.cyan, // color14
"terminal.ansiBrightWhite": paletteAnsi.bright.white, // color15
"terminal.selectionBackground": palette.surface2,
"terminal.inactiveSelectionBackground": opacity(palette.surface2, 0.5),
"terminalCursor.background": palette.base,
Expand Down
12 changes: 11 additions & 1 deletion packages/catppuccin-vsc/src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import type { AccentName, Colors, FlavorName } from "@catppuccin/palette";
import type {
AccentName,
Colors,
AnsiColors,
FlavorName,
} from "@catppuccin/palette";

import type { Uri } from "vscode";

Expand All @@ -23,6 +28,10 @@ export type CatppuccinBracketMode =
| "neovim";

export type CatppuccinPalette = Colors<string>;
export type CatppuccinPaletteAnsi = {
normal: AnsiColors<string>;
bright: AnsiColors<string>;
};

type FlavorsPlusAll<T> = { all: T } & { [k in CatppuccinFlavor]: T };

Expand Down Expand Up @@ -78,6 +87,7 @@ export type ThemePaths = {
export type ThemeContext = {
flavor: CatppuccinFlavor;
palette: CatppuccinPalette;
paletteAnsi: CatppuccinPaletteAnsi;
options: ThemeOptions;
isLatte: boolean;
};
2 changes: 1 addition & 1 deletion packages/catppuccin-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}
},
"dependencies": {
"@catppuccin/palette": "^1.1.1"
"@catppuccin/palette": "^1.7.1"
},
"devDependencies": {
"@tsconfig/node20": "^20.1.4",
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1608,18 +1608,18 @@ __metadata:
languageName: node
linkType: hard

"@catppuccin/palette@npm:^1.1.1":
version: 1.1.1
resolution: "@catppuccin/palette@npm:1.1.1"
checksum: 10c0/ed913c512b4f51166c8a9041977a20a47095c76176e3e0cb87083816a7a3bbcc24e681ffcd431638833c55d95598afb909ffcdc5875e6a0df30e7856117284bf
"@catppuccin/palette@npm:^1.7.1":
version: 1.7.1
resolution: "@catppuccin/palette@npm:1.7.1"
checksum: 10c0/b4577ad742310ccfd3394791be96ef8787fc6c3e90c7b9ca6dfbe12fb5e63ad8c7d1627846df4744b8edaee19ed98a2c34a292dc5e4ae8a3e877c5afafcc62d2
languageName: node
linkType: hard

"@catppuccin/vsc-storybook@workspace:packages/catppuccin-vsc-storybook":
version: 0.0.0-use.local
resolution: "@catppuccin/vsc-storybook@workspace:packages/catppuccin-vsc-storybook"
dependencies:
"@catppuccin/palette": "npm:^1.1.1"
"@catppuccin/palette": "npm:^1.7.1"
"@fontsource/jetbrains-mono": "npm:^5.0.20"
"@storybook/addon-essentials": "npm:^8.0.9"
"@storybook/addon-styling": "npm:^1.3.7"
Expand Down Expand Up @@ -1681,7 +1681,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@catppuccin/vscode@workspace:packages/catppuccin-vscode"
dependencies:
"@catppuccin/palette": "npm:^1.1.1"
"@catppuccin/palette": "npm:^1.7.1"
"@tsconfig/node20": "npm:^20.1.4"
"@types/node": "npm:^20.12.7"
catppuccin-vsc: "workspace:*"
Expand Down Expand Up @@ -5413,7 +5413,7 @@ __metadata:
resolution: "catppuccin-vsc@workspace:packages/catppuccin-vsc"
dependencies:
"@actions/core": "npm:^1.10.1"
"@catppuccin/palette": "npm:^1.1.1"
"@catppuccin/palette": "npm:^1.7.1"
"@catppuccin/vsc-typegen": "workspace:*"
"@tsconfig/node18": "npm:^18.2.4"
"@types/node": "npm:^20.12.7"
Expand Down

0 comments on commit 034def5

Please sign in to comment.