Skip to content

Commit b684a64

Browse files
committed
fix bracket colors (needs refactor
1 parent 679bba3 commit b684a64

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/style/themes.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// todo: line numbers, {} [] () brackets, types, variables, arguments
21
import type { editor } from 'monaco-editor';
32

43
import dracula from 'monaco-themes/themes/Dracula.json';
@@ -8,6 +7,7 @@ import solarizedLight from 'monaco-themes/themes/Solarized-light.json';
87
import { CatppuccinFlavor, flavors, ColorFormat } from '@catppuccin/palette';
98

109
type Color = `#${string}`;
10+
type Extra = Record<string, Color>;
1111

1212
export interface Theme {
1313
id: string;
@@ -74,7 +74,7 @@ const themes: Themes = {
7474
diffAddition: '#3fb950', // green.3
7575
diffDeletion: '#f85149', // red.4
7676
},
77-
}),
77+
}, {}),
7878
},
7979
'light': {
8080
id: 'light',
@@ -113,7 +113,7 @@ const themes: Themes = {
113113
diffAddition: '#2da44e', // green.4
114114
diffDeletion: '#cf222e', // red.5
115115
},
116-
}),
116+
}, {}),
117117
},
118118
'dracula': {
119119
id: 'dracula',
@@ -241,7 +241,8 @@ interface MonacoThemeProps {
241241
}
242242

243243
export function makeMonacoTheme(
244-
props: MonacoThemeProps
244+
props: MonacoThemeProps,
245+
extra: Extra
245246
): editor.IStandaloneThemeData {
246247
const colors = Object.fromEntries(
247248
Object.entries(props.colors).map(([key, color]) => [
@@ -250,6 +251,13 @@ export function makeMonacoTheme(
250251
])
251252
) as Record<keyof MonacoThemeProps['colors'], string>;
252253

254+
let editorColors: Extra = {
255+
'editor.background': `#${colors.background}`,
256+
'editor.foreground': `#${colors.primary}`,
257+
};
258+
259+
editorColors = { ...editorColors, ...extra };
260+
253261
return {
254262
base: props.base,
255263
inherit: true,
@@ -284,10 +292,7 @@ export function makeMonacoTheme(
284292
{ token: 'addition.diff', foreground: colors.diffAddition },
285293
{ token: 'deletion.diff', foreground: colors.diffDeletion },
286294
],
287-
colors: {
288-
'editor.background': `#${colors.background}`,
289-
'editor.foreground': `#${colors.primary}`,
290-
},
295+
colors: editorColors
291296
};
292297
}
293298

@@ -329,7 +334,7 @@ export function createCatppuccinTheme(flavor: CatppuccinFlavor): Theme {
329334
primary: color(flavor.colors.text),
330335
background: color(flavor.colors.mantle),
331336
string: color(flavor.colors.green),
332-
comment: color(flavor.colors.overlay0),
337+
comment: color(flavor.colors.overlay2),
333338
delimiter: color(flavor.colors.overlay2),
334339
annotation: color(flavor.colors.yellow),
335340
constant: color(flavor.colors.peach),
@@ -351,6 +356,10 @@ export function createCatppuccinTheme(flavor: CatppuccinFlavor): Theme {
351356
diffAddition: color(flavor.colors.green),
352357
diffDeletion: color(flavor.colors.red),
353358
}
359+
}, {
360+
"editorBracketHighlight.foreground1": color(flavor.colors.overlay2),
361+
"editorBracketHighlight.foreground2": color(flavor.colors.overlay2),
362+
"editorBracketHighlight.foreground3": color(flavor.colors.overlay2)
354363
});
355364

356365
return {

0 commit comments

Comments
 (0)