diff --git a/scripts/theme/theme.test.ts b/scripts/theme/theme.test.ts index 67ee3b3883..10710bf76d 100644 --- a/scripts/theme/theme.test.ts +++ b/scripts/theme/theme.test.ts @@ -187,6 +187,18 @@ describe("IntelliJ theme import", () => { }); }); + it("takes what a Darcula-based scheme leaves out from Darcula", () => { + const s = convertIcls(` + + + `); + expect(s.tokens["--bg-editor"]).toBe("#2b2b2b"); + expect(s.tokens["--syn-keyword"]).toBe("#ff8800"); + // An empty entry of its own replaces Darcula's colour. + expect(s.tokens["--syn-string"]).toBeUndefined(); + expect(convertIcls(``).tokens).toEqual({}); + }); + it("only targets tokens that exist in tokens.css", () => { const declared = new Set([...css.matchAll(/(--[a-z0-9-]+)\s*:/g)].map((m) => m[1]!)); // Read with a fallback by the editor (no tokens.css default), still themeable. diff --git a/src/features/plugins/intellijDarcula.ts b/src/features/plugins/intellijDarcula.ts new file mode 100644 index 0000000000..7f3708e81d --- /dev/null +++ b/src/features/plugins/intellijDarcula.ts @@ -0,0 +1,104 @@ +/** + * IntelliJ's bundled Darcula editor scheme (`DefaultColorSchemesManager.xml`) as `convertIcls` reads it. + * A theme's `.icls` with `parent_scheme="Darcula"` lists only what differs, and takes the rest from here. + */ +export const DARCULA_TOKENS: Readonly> = { + "--gutter-added": "#384c38", + "--gutter-modified": "#374752", + "--gutter-deleted": "#656e76", + "--caret": "#bbbbbb", + "--bg-current-line": "#323232", + "--bg-console": "#2b2b2b", + "--vcs-added": "#629755", + "--vcs-deleted": "#6c6c6c", + "--vcs-ignored": "#848504", + "--vcs-conflict": "#d5756c", + "--vcs-modified": "#6897bb", + "--vcs-untracked": "#d1675a", + "--border-indent-guide": "#373737", + "--fg-line-number": "#606366", + "--fg-line-number-current": "#a4a3a3", + "--border-method-separator": "#4d4d4d", + "--border-right-margin": "#4d4d4d", + "--border-indent-guide-active": "#505050", + "--bg-editor-selection": "#214283", + "--fg-whitespace": "#606060", + "--bg-breakpoint-line": "#3a2323", + "--ansi-black": "#000000", + "--terminal-ansi-black": "#000000", + "--ansi-blue": "#3993d4", + "--terminal-ansi-blue": "#3993d4", + "--ansi-bright-blue": "#1fb0ff", + "--terminal-ansi-bright-blue": "#1fb0ff", + "--ansi-cyan": "#00a3a3", + "--terminal-ansi-cyan": "#00a3a3", + "--ansi-bright-cyan": "#00e5e5", + "--terminal-ansi-bright-cyan": "#00e5e5", + "--ansi-bright-black": "#595959", + "--terminal-ansi-bright-black": "#595959", + "--ansi-white": "#808080", + "--terminal-ansi-white": "#808080", + "--ansi-green": "#5c962c", + "--terminal-ansi-green": "#5c962c", + "--ansi-bright-green": "#4fc414", + "--terminal-ansi-bright-green": "#4fc414", + "--ansi-magenta": "#a771bf", + "--terminal-ansi-magenta": "#a771bf", + "--ansi-bright-magenta": "#ed7eed", + "--terminal-ansi-bright-magenta": "#ed7eed", + "--ansi-red": "#f0524f", + "--terminal-ansi-red": "#f0524f", + "--ansi-bright-red": "#ff4050", + "--terminal-ansi-bright-red": "#ff4050", + "--ansi-bright-white": "#ffffff", + "--terminal-ansi-bright-white": "#ffffff", + "--ansi-yellow": "#a68a0d", + "--terminal-ansi-yellow": "#a68a0d", + "--ansi-bright-yellow": "#e5bf00", + "--terminal-ansi-bright-yellow": "#e5bf00", + "--syn-inline-value": "#666d75", + "--syn-constant": "#9876aa", + "--syn-doc-comment": "#629755", + "--syn-doc-comment-tag": "#629755", + "--syn-doc-markup": "#77b767", + "--syn-function-call": "#a9b7c6", + "--syn-function": "#ffc66d", + "--syn-variable": "#a9b7c6", + "--syn-property": "#9876aa", + "--syn-keyword": "#cc7832", + "--syn-comment": "#808080", + "--syn-annotation": "#bbb529", + "--syn-decorator": "#bbb529", + "--syn-number": "#6897bb", + "--syn-punct": "#a9b7c6", + "--syn-string": "#6a8759", + "--syn-escape": "#cc7832", + "--diff-conflict-stripe": "#8f5247", + "--diff-deleted": "#484a4a", + "--diff-deleted-stripe": "#656e76", + "--diff-inserted": "#294436", + "--diff-inserted-stripe": "#447152", + "--diff-modified": "#385570", + "--diff-modified-stripe": "#43698d", + "--syn-doc-comment-tag-value": "#8a653b", + "--wave-error": "#bc3f3c", + "--fg-fold-placeholder": "#8c8c8c", + "--bg-fold-placeholder": "#3a3a3a", + "--bg-identifier-under-caret": "#344134", + "--fg-inlay": "#787878", + "--bg-inlay": "#3b3b3b", + "--bg-matched-brace": "#3b514d", + "--fg-unused": "#72737a", + "--bg-search-result": "#155221", + "--fg-editor": "#a9b7c6", + "--bg-editor": "#2b2b2b", + "--bg-text-search-result": "#32593d", + "--syn-todo": "#a8c023", + "--bg-identifier-under-caret-write": "#40332b", + "--syn-rainbow-1": "#be7070", + "--syn-rainbow-2": "#3d7676", + "--syn-rainbow-3": "#be9970", + "--syn-rainbow-4": "#9d527c", + "--editor-error-decoration": "underline wavy #bc3f3c", + "--bg-editor-gutter": "#2b2b2b", +}; diff --git a/src/features/plugins/intellijTheme.ts b/src/features/plugins/intellijTheme.ts index 67eeddd32e..07d2874a8f 100644 --- a/src/features/plugins/intellijTheme.ts +++ b/src/features/plugins/intellijTheme.ts @@ -4,11 +4,13 @@ * plugin into an OpenIDEA theme plugin package. The mapping covers the main * keys only; anything unmapped keeps the built-in value of the base (`kind`). * - * Pure functions without imports: Settings › Plugins › Import IntelliJ Theme + * Pure functions, importing only data: Settings › Plugins › Import IntelliJ Theme * uses them on what the host read from the plugin (`plugin_read_intellij_theme`), * and so does the command line (`scripts/theme/import-intellij-theme.ts`). */ +import { DARCULA_TOKENS } from "./intellijDarcula.ts"; + /** OpenIDEA token ← IntelliJ `ui` keys, first present wins. `*.prop` wildcards apply too. */ export const UI_KEYS: Record = { "--bg-app": ["Panel.background"], @@ -358,6 +360,12 @@ export function convertIcls(xml: string): { name: string; dark: boolean | null; tokens["--syn-comment-style"] = Number(parts.get("FONT_TYPE")) & 2 ? "italic" : "normal"; } } + if (parent === "Darcula") { + // IntelliJ replaces a parent's attribute as a whole: what the file names, even empty or by baseAttributes, wins. + const keys = [...body.matchAll(/