Skip to content

Commit 3b0df94

Browse files
committed
feat(syntax): add support for Haskell (#360)
1 parent 67bd19a commit 3b0df94

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

packages/catppuccin-vsc/src/theme/semanticTokens.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ export const getSemanticTokens = (context: ThemeContext): SemanticTokens => {
3434
"type.defaultLibrary:go": { foreground: palette.mauve },
3535
"variable.readonly.defaultLibrary:go": { foreground: palette.mauve },
3636

37+
// Haskell:
38+
"enumMember:haskell": { foreground: palette.blue }, // data constructor
39+
"enum:haskell": { foreground: palette.yellow }, // type constructor
40+
"class:haskell": { foreground: palette.yellow, fontStyle: "" }, // typeclass
41+
"interface:haskell": { foreground: palette.pink }, // type family
42+
3743
// TOML syntax
3844
tomlArrayKey: { foreground: palette.blue, fontStyle: "" },
3945
tomlTableKey: { foreground: palette.blue, fontStyle: "" },
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import type { TextmateColors, ThemeContext } from "@/types";
2+
3+
const tokens = (context: ThemeContext): TextmateColors => {
4+
const { palette } = context;
5+
6+
/*
7+
should preferrably appear visually distinct:
8+
- data constructors -> use blue
9+
- type constructors -> use yellow+italic
10+
- typeclasses -> use yellow
11+
*/
12+
13+
return [
14+
{
15+
name: "data constructors",
16+
scope: [
17+
"variable.other.enummember",
18+
"meta.declaration.data constant.other",
19+
"constant.other",
20+
],
21+
settings: { foreground: palette.blue },
22+
// like functions (capitalized -> still visually distinct)
23+
},
24+
{
25+
name: "type constructors",
26+
scope: ["entity.name.type", "storage.type"],
27+
settings: {
28+
foreground: palette.yellow,
29+
fontStyle: "italic",
30+
},
31+
},
32+
{
33+
name: "typeclasses",
34+
scope: ["entity.name.type.class"],
35+
settings: {
36+
foreground: palette.yellow,
37+
fontStyle: "",
38+
},
39+
},
40+
{
41+
name: "module name",
42+
scope: "meta.declaration.module.haskell entity.name.namespace.haskell",
43+
settings: {
44+
foreground: palette.peach, // as in Rust
45+
},
46+
},
47+
{
48+
name: "imports",
49+
scope: ["entity.name.namespace"],
50+
settings: { foreground: palette.rosewater },
51+
},
52+
{
53+
name: "type parameters",
54+
scope: ["entity.name.type.parameter", "variable.other.generic-type"],
55+
settings: { foreground: palette.maroon },
56+
},
57+
{
58+
name: "pragma keywords",
59+
scope: [" keyword.other.preprocessor"],
60+
settings: { foreground: palette.red },
61+
},
62+
{
63+
name: "pragma arguments",
64+
scope: [" keyword.other.preprocessor.extension"],
65+
settings: { foreground: palette.peach },
66+
},
67+
{
68+
name: "preprocessor directives",
69+
scope: ["meta.preprocessor"],
70+
settings: { foreground: palette.rosewater },
71+
},
72+
73+
{
74+
name: "type families",
75+
scope: ["entity.name.type.interface"],
76+
settings: { foreground: palette.pink },
77+
// we need something distinct from typeclasses
78+
// -> pick pink which is used for meta-variables in Rust
79+
},
80+
{
81+
name: "getters in data constructors/records",
82+
scope: ["variable.other.property", "variable.other.member"],
83+
settings: { foreground: palette.blue },
84+
},
85+
{
86+
name: "fix else keyword",
87+
scope: ["keyword.control.else.haskell"],
88+
settings: { foreground: palette.mauve },
89+
// catppuccin default sets to yellow considering it preprocessor-like, which it is not for Haskell
90+
},
91+
];
92+
};
93+
94+
export default tokens;
95+
96+

packages/catppuccin-vsc/src/theme/tokens/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import dotenv from "./dotenv";
99
import gdscript from "./gdscript";
1010
import golang from "./golang";
1111
import graphql from "./graphql";
12+
import haskell from "./haskell";
1213
import html from "./html";
1314
import java from "./java";
1415
import javascript from "./javascript";
@@ -296,6 +297,7 @@ export default function tokens(context: ThemeContext): TextmateColors {
296297
gdscript,
297298
golang,
298299
graphql,
300+
haskell,
299301
html,
300302
java,
301303
javascript,

0 commit comments

Comments
 (0)