Merge pull request #2231 from zed-industries/nate/add-gruvbox

Add Gruvbox Theme
This commit is contained in:
Nate Butler
2023-03-06 18:49:26 -08:00
committed by GitHub
21 changed files with 397 additions and 211 deletions
+36 -31
View File
@@ -1,7 +1,7 @@
import * as fs from "fs"
import toml from "toml"
import { schemeMeta } from "./colorSchemes"
import { Meta } from "./themes/common/colorScheme"
import { Meta, Verification } from "./themes/common/colorScheme"
import https from "https"
import crypto from "crypto"
@@ -36,40 +36,45 @@ function getLicenseText(
callback: (meta: Meta, license_text: string) => void
) {
for (let meta of schemeMeta) {
// The following copied from the example code on nodejs.org:
// https://nodejs.org/api/http.html#httpgetoptions-callback
https
.get(meta.license.https_url, (res) => {
const { statusCode } = res
if (typeof meta.license.license_text == "string") {
callback(meta, meta.license.license_text)
} else {
let license_text_obj: Verification = meta.license.license_text;
// The following copied from the example code on nodejs.org:
// https://nodejs.org/api/http.html#httpgetoptions-callback
https
.get(license_text_obj.https_url, (res) => {
const { statusCode } = res
if (statusCode < 200 || statusCode >= 300) {
throw new Error(
`Failed to fetch license for: ${meta.name}, Status Code: ${statusCode}`
)
}
res.setEncoding("utf8")
let rawData = ""
res.on("data", (chunk) => {
rawData += chunk
})
res.on("end", () => {
const hash = crypto
.createHash("sha256")
.update(rawData)
.digest("hex")
if (meta.license.license_checksum == hash) {
callback(meta, rawData)
} else {
throw Error(
`Checksum for ${meta.name} did not match file downloaded from ${meta.license.https_url}`
if (statusCode < 200 || statusCode >= 300) {
throw new Error(
`Failed to fetch license for: ${meta.name}, Status Code: ${statusCode}`
)
}
res.setEncoding("utf8")
let rawData = ""
res.on("data", (chunk) => {
rawData += chunk
})
res.on("end", () => {
const hash = crypto
.createHash("sha256")
.update(rawData)
.digest("hex")
if (license_text_obj.license_checksum == hash) {
callback(meta, rawData)
} else {
throw Error(
`Checksum for ${meta.name} did not match file downloaded from ${license_text_obj.https_url}`
)
}
})
})
})
.on("error", (e) => {
throw e
})
.on("error", (e) => {
throw e
})
}
}
}
+6 -4
View File
@@ -34,10 +34,12 @@ export const meta: Meta = {
author: "EliverLara",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/EliverLara/Andromeda/master/LICENSE.md",
license_checksum:
"2f7886f1a05cefc2c26f5e49de1a39fa4466413c1ccb06fc80960e73f5ed4b89",
license_text: {
https_url:
"https://raw.githubusercontent.com/EliverLara/Andromeda/master/LICENSE.md",
license_checksum:
"2f7886f1a05cefc2c26f5e49de1a39fa4466413c1ccb06fc80960e73f5ed4b89",
}
},
url: "https://github.com/EliverLara/Andromeda",
}
+5 -3
View File
@@ -55,9 +55,11 @@ export const meta: Meta = {
author: "atelierbram",
license: {
SPDX: "MIT",
https_url: "https://atelierbram.mit-license.org/license.txt",
license_checksum:
"f95ce526ef4e7eecf7a832bba0e3451cc1000f9ce63eb01ed6f64f8109f5d0a5",
license_text: {
https_url: "https://atelierbram.mit-license.org/license.txt",
license_checksum:
"f95ce526ef4e7eecf7a832bba0e3451cc1000f9ce63eb01ed6f64f8109f5d0a5",
}
},
url: "https://atelierbram.github.io/syntax-highlighting/atelier-schemes/cave/",
}
+5 -3
View File
@@ -35,9 +35,11 @@ export const meta: Meta = {
author: "atelierbram",
license: {
SPDX: "MIT",
https_url: "https://atelierbram.mit-license.org/license.txt",
license_checksum:
"f95ce526ef4e7eecf7a832bba0e3451cc1000f9ce63eb01ed6f64f8109f5d0a5",
license_text: {
https_url: "https://atelierbram.mit-license.org/license.txt",
license_checksum:
"f95ce526ef4e7eecf7a832bba0e3451cc1000f9ce63eb01ed6f64f8109f5d0a5",
}
},
url: "https://atelierbram.github.io/syntax-highlighting/atelier-schemes/sulphurpool/",
}
+4
View File
@@ -29,6 +29,10 @@ export interface Meta {
export interface License {
SPDX: SPDXExpression
/// A url where we can download the license's text
license_text: Verification | string
}
export interface Verification {
https_url: string
license_checksum: string
}
+255
View File
@@ -0,0 +1,255 @@
import chroma from "chroma-js"
import { Meta, ThemeSyntax } from "./common/colorScheme"
import { colorRamp, createColorScheme } from "./common/ramps"
const name = "Gruvbox"
const color = {
dark0_hard: "#1d2021",
dark0: "#282828",
dark0_soft: "#32302f",
dark1: "#3c3836",
dark2: "#504945",
dark3: "#665c54",
dark4: "#7c6f64",
dark4_256: "#7c6f64",
gray_245: "#928374",
gray_244: "#928374",
light0_hard: "#f9f5d7",
light0: "#fbf1c7",
light0_soft: "#f2e5bc",
light1: "#ebdbb2",
light2: "#d5c4a1",
light3: "#bdae93",
light4: "#a89984",
light4_256: "#a89984",
bright_red: "#fb4934",
bright_green: "#b8bb26",
bright_yellow: "#fabd2f",
bright_blue: "#83a598",
bright_purple: "#d3869b",
bright_aqua: "#8ec07c",
bright_orange: "#fe8019",
neutral_red: "#cc241d",
neutral_green: "#98971a",
neutral_yellow: "#d79921",
neutral_blue: "#458588",
neutral_purple: "#b16286",
neutral_aqua: "#689d6a",
neutral_orange: "#d65d0e",
faded_red: "#9d0006",
faded_green: "#79740e",
faded_yellow: "#b57614",
faded_blue: "#076678",
faded_purple: "#8f3f71",
faded_aqua: "#427b58",
faded_orange: "#af3a03",
}
interface ThemeColors {
red: string
green: string
yellow: string
blue: string
purple: string
aqua: string
orange: string
gray: string
}
const darkNeutrals = [
color.dark1,
color.dark2,
color.dark3,
color.dark4,
color.light4,
color.light3,
color.light2,
color.light1,
color.light0,
]
const dark: ThemeColors = {
red: color.bright_red,
green: color.bright_green,
yellow: color.bright_yellow,
blue: color.bright_blue,
purple: color.bright_purple,
aqua: color.bright_aqua,
orange: color.bright_orange,
gray: color.light4,
}
const lightNeutrals = [
color.light1,
color.light2,
color.light3,
color.light4,
color.dark4,
color.dark3,
color.dark2,
color.dark1,
color.dark0,
]
const light: ThemeColors = {
red: color.faded_red,
green: color.faded_green,
yellow: color.faded_yellow,
blue: color.faded_blue,
purple: color.faded_purple,
aqua: color.faded_aqua,
orange: color.faded_orange,
gray: color.dark4,
}
const darkHardNeutral = [color.dark0_hard, ...darkNeutrals]
const darkNeutral = [color.dark0, ...darkNeutrals]
const darkSoftNeutral = [color.dark0_soft, ...darkNeutrals]
const lightHardNeutral = [color.light0_hard, ...lightNeutrals]
const lightNeutral = [color.light0, ...lightNeutrals]
const lightSoftNeutral = [color.light0_soft, ...lightNeutrals]
interface Variant {
name: string
appearance: "light" | "dark"
colors: ThemeColors
}
const variant: Variant[] = [
{
name: "Dark Hard",
appearance: "dark",
colors: dark,
},
{
name: "Dark",
appearance: "dark",
colors: dark,
},
{
name: "Dark Soft",
appearance: "dark",
colors: dark,
},
{
name: "Light Hard",
appearance: "light",
colors: light,
},
{
name: "Light",
appearance: "light",
colors: light,
},
{
name: "Light Soft",
appearance: "light",
colors: light,
},
]
const buildVariant = (variant: Variant) => {
const { colors } = variant
const name = `Gruvbox ${variant.name}`
const isLight = variant.appearance === "light"
let neutral: string[] = []
switch (variant.name) {
case "Dark Hard": {
neutral = darkHardNeutral
break
}
case "Dark": {
neutral = darkNeutral
break
}
case "Dark Soft": {
neutral = darkSoftNeutral
break
}
case "Light Hard": {
neutral = lightHardNeutral
break
}
case "Light": {
neutral = lightNeutral
break
}
case "Light Soft": {
neutral = lightSoftNeutral
break
}
}
const ramps = {
neutral: chroma.scale(isLight ? neutral.reverse() : neutral),
red: colorRamp(chroma(variant.colors.red)),
orange: colorRamp(chroma(variant.colors.orange)),
yellow: colorRamp(chroma(variant.colors.yellow)),
green: colorRamp(chroma(variant.colors.green)),
cyan: colorRamp(chroma(variant.colors.aqua)),
blue: colorRamp(chroma(variant.colors.blue)),
violet: colorRamp(chroma(variant.colors.purple)),
magenta: colorRamp(chroma(variant.colors.gray)),
}
const syntax: ThemeSyntax = {
primary: { color: neutral[isLight ? 0 : 8] },
"text.literal": { color: colors.blue },
comment: { color: colors.gray },
punctuation: { color: neutral[isLight ? 1 : 7] },
"punctuation.bracket": { color: neutral[isLight ? 3 : 5] },
"punctuation.list_marker": { color: neutral[isLight ? 0 : 8] },
operator: { color: colors.aqua },
boolean: { color: colors.purple },
number: { color: colors.purple },
string: { color: colors.green },
"string.special": { color: colors.purple },
"string.special.symbol": { color: colors.aqua },
"string.regex": { color: colors.orange },
type: { color: colors.yellow },
enum: { color: colors.orange },
tag: { color: colors.aqua },
constant: { color: colors.yellow },
keyword: { color: colors.red },
function: { color: colors.green },
"function.builtin": { color: colors.red },
variable: { color: colors.blue },
property: { color: neutral[isLight ? 0 : 8] },
embedded: { color: colors.aqua },
linkText: { color: colors.aqua },
linkUri: { color: colors.purple },
title: { color: colors.green },
}
return createColorScheme(name, isLight, ramps, syntax)
}
// Variants
export const darkHard = buildVariant(variant[0])
export const darkDefault = buildVariant(variant[1])
export const darkSoft = buildVariant(variant[2])
export const lightHard = buildVariant(variant[3])
export const lightDefault = buildVariant(variant[4])
export const lightSoft = buildVariant(variant[5])
export const meta: Meta = {
name,
license: {
SPDX: "MIT", // "MIT/X11"
license_text: "Copyright <YEAR> <COPYRIGHT HOLDER>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/ or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
},
author: "morhetz <morhetz@gmail.com>",
url: "https://github.com/morhetz/gruvbox",
}
+6
View File
@@ -0,0 +1,6 @@
import { darkHard as dark, meta as commonMeta } from "./gruvbox-common";
let meta = { ...commonMeta };
meta.name = `${commonMeta.name} Dark Hard`
export { dark, meta }
+7
View File
@@ -0,0 +1,7 @@
import { darkSoft as dark, meta as commonMeta } from "./gruvbox-common";
let meta = { ...commonMeta };
meta.name = `${commonMeta.name} Dark Soft`
export { dark, meta }
+7
View File
@@ -0,0 +1,7 @@
import { darkDefault as dark, meta as commonMeta } from "./gruvbox-common";
let meta = { ...commonMeta };
meta.name = `${commonMeta.name} Dark`
export { dark, meta }
+6
View File
@@ -0,0 +1,6 @@
import { lightHard as light, meta as commonMeta } from "./gruvbox-common";
let meta = { ...commonMeta };
meta.name = `${commonMeta.name} Dark Soft`
export { light, meta }
+6
View File
@@ -0,0 +1,6 @@
import { lightSoft as light, meta as commonMeta } from "./gruvbox-common";
let meta = { ...commonMeta };
meta.name = `${commonMeta.name} Light Soft`
export { light, meta }
+6
View File
@@ -0,0 +1,6 @@
import { lightDefault as light, meta as commonMeta } from "./gruvbox-common";
let meta = { ...commonMeta };
meta.name = `${commonMeta.name} Light`
export { light, meta }
+6 -4
View File
@@ -74,10 +74,12 @@ export const meta: Meta = {
author: "simurai",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/atom/atom/master/packages/one-light-ui/LICENSE.md",
license_checksum:
"d5af8fc171f6f600c0ab4e7597dca398dda80dbe6821ce01cef78e859e7a00f8",
license_text: {
https_url:
"https://raw.githubusercontent.com/atom/atom/master/packages/one-light-ui/LICENSE.md",
license_checksum:
"d5af8fc171f6f600c0ab4e7597dca398dda80dbe6821ce01cef78e859e7a00f8",
}
},
url: "https://github.com/atom/atom/tree/master/packages/one-dark-ui",
}
+6 -4
View File
@@ -73,10 +73,12 @@ export const meta: Meta = {
author: "simurai",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/atom/atom/master/packages/one-light-ui/LICENSE.md",
license_checksum:
"d5af8fc171f6f600c0ab4e7597dca398dda80dbe6821ce01cef78e859e7a00f8",
license_text: {
https_url:
"https://raw.githubusercontent.com/atom/atom/master/packages/one-light-ui/LICENSE.md",
license_checksum:
"d5af8fc171f6f600c0ab4e7597dca398dda80dbe6821ce01cef78e859e7a00f8",
}
},
url: "https://github.com/atom/atom/tree/master/packages/one-light-ui",
}
+6 -4
View File
@@ -34,10 +34,12 @@ export const meta: Meta = {
author: "edunfelt",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/edunfelt/base16-rose-pine-scheme/main/LICENSE",
license_checksum:
"6ca1b9da8c78c8441c5aa43d024a4e4a7bf59d1ecca1480196e94fda0f91ee4a",
license_text: {
https_url:
"https://raw.githubusercontent.com/edunfelt/base16-rose-pine-scheme/main/LICENSE",
license_checksum:
"6ca1b9da8c78c8441c5aa43d024a4e4a7bf59d1ecca1480196e94fda0f91ee4a",
}
},
url: "https://github.com/edunfelt/base16-rose-pine-scheme",
}
+6 -4
View File
@@ -34,10 +34,12 @@ export const meta: Meta = {
author: "edunfelt",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/edunfelt/base16-rose-pine-scheme/main/LICENSE",
license_checksum:
"6ca1b9da8c78c8441c5aa43d024a4e4a7bf59d1ecca1480196e94fda0f91ee4a",
license_text: {
https_url:
"https://raw.githubusercontent.com/edunfelt/base16-rose-pine-scheme/main/LICENSE",
license_checksum:
"6ca1b9da8c78c8441c5aa43d024a4e4a7bf59d1ecca1480196e94fda0f91ee4a",
}
},
url: "https://github.com/edunfelt/base16-rose-pine-scheme",
}
+6 -4
View File
@@ -32,10 +32,12 @@ export const meta: Meta = {
author: "edunfelt",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/edunfelt/base16-rose-pine-scheme/main/LICENSE",
license_checksum:
"6ca1b9da8c78c8441c5aa43d024a4e4a7bf59d1ecca1480196e94fda0f91ee4a",
license_text: {
https_url:
"https://raw.githubusercontent.com/edunfelt/base16-rose-pine-scheme/main/LICENSE",
license_checksum:
"6ca1b9da8c78c8441c5aa43d024a4e4a7bf59d1ecca1480196e94fda0f91ee4a",
}
},
url: "https://github.com/edunfelt/base16-rose-pine-scheme",
}
+6 -4
View File
@@ -32,10 +32,12 @@ export const meta: Meta = {
author: "gessig",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/gessig/base16-sandcastle-scheme/master/LICENSE",
license_checksum:
"8399d44b4d935b60be9fee0a76d7cc9a817b4f3f11574c9d6d1e8fd57e72ffdc",
license_text: {
https_url:
"https://raw.githubusercontent.com/gessig/base16-sandcastle-scheme/master/LICENSE",
license_checksum:
"8399d44b4d935b60be9fee0a76d7cc9a817b4f3f11574c9d6d1e8fd57e72ffdc",
}
},
url: "https://github.com/gessig/base16-sandcastle-scheme",
}
+6 -4
View File
@@ -35,10 +35,12 @@ export const meta: Metadata = {
author: "Ethan Schoonover",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/altercation/solarized/master/LICENSE",
license_checksum:
"494aefdabf86acce06bd63001ad8aedad4ee38da23509d3f917d95aa3368b9a6",
license_text: {
https_url:
"https://raw.githubusercontent.com/altercation/solarized/master/LICENSE",
license_checksum:
"494aefdabf86acce06bd63001ad8aedad4ee38da23509d3f917d95aa3368b9a6",
}
},
url: "https://github.com/altercation/solarized",
}
-138
View File
@@ -1,138 +0,0 @@
import chroma from "chroma-js"
import { colorRamp, createColorScheme } from "../common/ramps"
const name = "Gruvbox"
const author = "Dawid Kurek (dawikur@gmail.com)"
const url = "https://github.com/morhetz/gruvbox"
const license = {
type: "MIT/X11",
url: "https://en.wikipedia.org/wiki/MIT_License",
}
export const dark = createColorScheme(`${name} Dark Medium`, false, {
neutral: chroma.scale([
"#282828",
"#3c3836",
"#504945",
"#665c54",
"#7C6F64",
"#928374",
"#A89984",
"#BDAE93",
"#D5C4A1",
"#EBDBB2",
"#FBF1C7",
]),
red: chroma.scale([
"#4D150F",
"#7D241A",
"#A31C17",
"#CC241D",
"#C83A29",
"#FB4934",
"#F06D61",
"#E6928E",
"#FFFFFF",
]),
orange: chroma.scale([
"#462307",
"#7F400C",
"#AB4A0B",
"#D65D0E",
"#CB6614",
"#FE8019",
"#F49750",
"#EBAE87",
"#FFFFFF",
]),
yellow: chroma.scale([
"#3D2C05",
"#7D5E17",
"#AC7A1A",
"#D79921",
"#E8AB28",
"#FABD2F",
"#F2C45F",
"#EBCC90",
"#FFFFFF",
]),
green: chroma.scale([
"#32330A",
"#5C5D13",
"#797814",
"#98971A",
"#93951E",
"#B8BB26",
"#C2C359",
"#CCCB8D",
"#FFFFFF",
]),
cyan: chroma.scale([
"#283D20",
"#47603E",
"#537D54",
"#689D6A",
"#719963",
"#8EC07C",
"#A1C798",
"#B4CEB5",
"#FFFFFF",
]),
blue: chroma.scale([
"#103738",
"#214C4D",
"#376A6C",
"#458588",
"#688479",
"#83A598",
"#92B3AE",
"#A2C2C4",
"#FFFFFF",
]),
violet: chroma.scale([
"#392228",
"#69434D",
"#8D4E6B",
"#B16286",
"#A86B7C",
"#D3869B",
"#D59BAF",
"#D8B1C3",
"#FFFFFF",
]),
magenta: chroma.scale([
"#48402C",
"#756D59",
"#867A69",
"#A89984",
"#BCAF8E",
"#EBDBB2",
"#DFD3BA",
"#D4CCC2",
"#FFFFFF",
]),
})
export const light = createColorScheme(`${name} Light Medium`, true, {
neutral: chroma.scale([
"#282828",
"#3c3836",
"#504945",
"#665c54",
"#7C6F64",
"#928374",
"#A89984",
"#BDAE93",
"#D5C4A1",
"#EBDBB2",
"#FBF1C7",
]),
red: colorRamp(chroma("#9d0006")),
orange: colorRamp(chroma("#af3a03")),
yellow: colorRamp(chroma("#b57614")),
green: colorRamp(chroma("#79740e")),
cyan: colorRamp(chroma("#427b58")),
blue: colorRamp(chroma("#076678")),
violet: colorRamp(chroma("#8f3f71")),
magenta: colorRamp(chroma("#d65d0e")),
})
+6 -4
View File
@@ -34,9 +34,11 @@ export const meta: Meta = {
url: "https://github.com/zoefiri/base16-sc",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/zoefiri/base16-sc/master/LICENSE",
license_checksum:
"fadcc834b7eaf2943800956600e8aeea4b495ecf6490f4c4b6c91556a90accaf",
license_text: {
https_url:
"https://raw.githubusercontent.com/zoefiri/base16-sc/master/LICENSE",
license_checksum:
"fadcc834b7eaf2943800956600e8aeea4b495ecf6490f4c4b6c91556a90accaf",
}
},
}