A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
imrpovement: color functions in theme, bold keywords (#2076)
Myles Scolnick91013eae4e08
diff --git a/frontend/package.json b/frontend/package.jsonindex 99db8854d8..760b652d77 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -129,6 +129,7 @@"swiper": "^11.1.9","tailwind-merge": "^2.5.2","tailwindcss-animate": "^1.0.7",+ "thememirror": "^2.0.1","timestring": "^7.0.0","typescript-memoize": "^1.1.1","use-resize-observer": "^9.1.0",diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yamlindex 02fafc7f6f..138f91a24d 100644--- a/frontend/pnpm-lock.yaml+++ b/frontend/pnpm-lock.yaml@@ -353,6 +353,9 @@ dependencies:tailwindcss-animate:specifier: ^1.0.7version: 1.0.7([email protected])+ thememirror:+ specifier: ^2.0.1+ version: 2.0.1(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])timestring:specifier: ^7.0.0version: 7.0.0@@ -17711,6 +17714,18 @@ packages:resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==}+ /[email protected](@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected]):+ resolution: {integrity: sha512-d5i6FVvWWPkwrm4cHLI3t9AT1OrkAt7Ig8dtdYSofgF7C/eiyNuq6zQzSTusWTde3jpW9WLvA9J/fzNKMUsd0w==}+ peerDependencies:+ '@codemirror/language': ^6.0.0+ '@codemirror/state': ^6.0.0+ '@codemirror/view': ^6.0.0+ dependencies:+ '@codemirror/language': 6.10.2+ '@codemirror/state': 6.4.1+ '@codemirror/view': 6.32.0+ dev: false+resolution: {integrity: sha512-YM/Fho1bQ3JFX9dgFQsBswc3aSTePXvtNHl3aXJTZNz/444yC86EVJR92aWMRNA0O9X0UfmojyCTUcT8Lbo5yA==}dependencies:diff --git a/frontend/src/core/codemirror/cm.ts b/frontend/src/core/codemirror/cm.tsindex 793e76cd02..b85ed8e985 100644--- a/frontend/src/core/codemirror/cm.ts+++ b/frontend/src/core/codemirror/cm.ts@@ -54,7 +54,8 @@ import { hintTooltip } from "./completion/hints";import { adaptiveLanguageConfiguration } from "./language/extension";import { historyCompartment } from "./editing/extensions";import { goToDefinitionBundle } from "./go-to-definition/extension";-import { HotkeyProvider } from "../hotkeys/hotkeys";+import type { HotkeyProvider } from "../hotkeys/hotkeys";+import { lightTheme } from "./theme/light";export interface CodeMirrorSetupOpts {cellId: CellId;@@ -130,7 +131,7 @@ export const basicBundle = (opts: CodeMirrorSetupOpts): Extension[] => {parent: document.querySelector<HTMLElement>("#App") ?? undefined,}),scrollActiveLineIntoView(),- theme === "dark" ? oneDark : [],+ theme === "dark" ? oneDark : lightTheme,hintTooltip(),copilotBundle(completionConfig),diff --git a/frontend/src/core/codemirror/theme/light.ts b/frontend/src/core/codemirror/theme/light.tsnew file mode 100644index 0000000000..806ab89f57--- /dev/null+++ b/frontend/src/core/codemirror/theme/light.ts@@ -0,0 +1,43 @@+/* Copyright 2024 Marimo. All rights reserved. */+import { createTheme } from "thememirror";+import { tags as t } from "@lezer/highlight";++export const lightTheme = createTheme({+ variant: "light",+ settings: {+ background: "#ffffff",+ foreground: "#000000",+ caret: "#000000",+ selection: "#d7d4f0",+ lineHighlight: "#f7f7f7",+ gutterBackground: "hsl(var(--color-background))",+ gutterForeground: "var(--gray-10)",+ },+ styles: [+ // Default codemirror light theme+ { tag: t.comment, color: "#708090" },+ { tag: t.variableName, color: "#000000" },+ { tag: [t.string, t.special(t.brace)], color: "#a11" },+ { tag: t.number, color: "#164" },+ { tag: t.bool, color: "#219" },+ { tag: t.null, color: "#219" },+ { tag: t.keyword, color: "#708", fontWeight: 500 },+ // { tag: t.operator, color: '#000' },+ { tag: t.className, color: "#00f" },+ { tag: t.definition(t.typeName), color: "#00f" },+ { tag: t.typeName, color: "#085" },+ { tag: t.angleBracket, color: "#000000" },+ { tag: t.tagName, color: "#170" },+ { tag: t.attributeName, color: "#00c" },+ // Adjustments+ { tag: t.operator, color: "#a2f", fontWeight: 500 },+ {+ tag: [t.function(t.variableName)],+ color: "#00c",+ },+ {+ tag: [t.propertyName],+ color: "#05a",+ },+ ],+});