1import { dark, light, mirage } from "ayu"
2import { ThemeSyntax } from "./syntax"
3import chroma from "chroma-js"
4import { colorRamp } from "./ramps"
5import { Meta } from "./colorScheme"
6
7export const ayu = {
8 dark,
9 light,
10 mirage,
11}
12
13export const buildTheme = (t: typeof dark, light: boolean) => {
14 const color = {
15 lightBlue: t.syntax.tag.hex(),
16 yellow: t.syntax.func.hex(),
17 blue: t.syntax.entity.hex(),
18 green: t.syntax.string.hex(),
19 teal: t.syntax.regexp.hex(),
20 red: t.syntax.markup.hex(),
21 orange: t.syntax.keyword.hex(),
22 lightYellow: t.syntax.special.hex(),
23 gray: t.syntax.comment.hex(),
24 purple: t.syntax.constant.hex(),
25 }
26
27 const syntax: ThemeSyntax = {
28 constant: { color: t.syntax.constant.hex() },
29 "string.regex": { color: t.syntax.regexp.hex() },
30 string: { color: t.syntax.string.hex() },
31 comment: { color: t.syntax.comment.hex() },
32 keyword: { color: t.syntax.keyword.hex() },
33 operator: { color: t.syntax.operator.hex() },
34 number: { color: t.syntax.constant.hex() },
35 type: { color: color.blue },
36 boolean: { color: color.purple },
37 "punctuation.special": { color: color.purple },
38 "string.special": { color: t.syntax.special.hex() },
39 function: { color: t.syntax.func.hex() },
40 }
41
42 return {
43 ramps: {
44 neutral: chroma.scale([
45 light ? t.editor.fg.hex() : t.editor.bg.hex(),
46 light ? t.editor.bg.hex() : t.editor.fg.hex(),
47 ]),
48 red: colorRamp(chroma(color.red)),
49 orange: colorRamp(chroma(color.orange)),
50 yellow: colorRamp(chroma(color.yellow)),
51 green: colorRamp(chroma(color.green)),
52 cyan: colorRamp(chroma(color.teal)),
53 blue: colorRamp(chroma(color.blue)),
54 violet: colorRamp(chroma(color.purple)),
55 magenta: colorRamp(chroma(color.lightBlue)),
56 },
57 syntax,
58 }
59}
60
61export const buildSyntax = (t: typeof dark): ThemeSyntax => {
62 return {
63 constant: { color: t.syntax.constant.hex() },
64 "string.regex": { color: t.syntax.regexp.hex() },
65 string: { color: t.syntax.string.hex() },
66 comment: { color: t.syntax.comment.hex() },
67 keyword: { color: t.syntax.keyword.hex() },
68 operator: { color: t.syntax.operator.hex() },
69 number: { color: t.syntax.constant.hex() },
70 type: { color: t.syntax.regexp.hex() },
71 "punctuation.special": { color: t.syntax.special.hex() },
72 "string.special": { color: t.syntax.special.hex() },
73 function: { color: t.syntax.func.hex() },
74 }
75}
76
77export const meta: Meta = {
78 name: "Ayu",
79 author: "dempfi",
80 license: {
81 SPDX: "MIT",
82 license_text: {
83 https_url:
84 "https://raw.githubusercontent.com/dempfi/ayu/master/LICENSE",
85 license_checksum:
86 "e0af0e0d1754c18ca075649d42f5c6d9a60f8bdc03c20dfd97105f2253a94173",
87 },
88 },
89 url: "https://github.com/dempfi/ayu",
90}