Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

fix(editor): Match PyCharm syntax colours and text weight

l0ng-aic8cea62eabac
diff --git a/src/editor/core/cm/highlight.ts b/src/editor/core/cm/highlight.ts
index ed68169df..0d9b01dea 100644
--- a/src/editor/core/cm/highlight.ts
+++ b/src/editor/core/cm/highlight.ts
@@ -18,6 +18,9 @@ function token(tag: Tag | Tag[], name: string, defaults: { italic?: string; bold
}
export const openideaHighlightStyle = HighlightStyle.define([
+ // Markdown tags whole links / quotes; listed first so marks, URL and title inside keep their own colours.
+ token(t.link, "link", { effect: "underline" }),
+ token(t.quote, "string"),
token([t.keyword, t.controlKeyword, t.moduleKeyword, t.operatorKeyword, t.definitionKeyword, t.modifier, t.null, t.bool, t.unit], "keyword"),
token(t.self, "self"),
token([t.string, t.special(t.string), t.character, t.attributeValue], "string"),
@@ -31,7 +34,9 @@ export const openideaHighlightStyle = HighlightStyle.define([
token([t.function(t.definition(t.variableName)), t.definition(t.function(t.variableName)), t.function(t.definition(t.propertyName))], "function"),
token([t.comment, t.lineComment, t.blockComment], "comment", { italic: "var(--syn-comment-style)" }),
token(t.docComment, "doc-comment", { italic: "italic" }),
- token([t.meta, t.annotation, t.macroName, t.documentMeta], "decorator"),
+ token([t.meta, t.annotation, t.macroName], "decorator"),
+ // `<!doctype>` is a sub-tag of `meta`; PyCharm leaves the XML prologue as plain text.
+ { tag: t.documentMeta, color: "var(--fg-editor)" },
token([t.constant(t.variableName), t.atom, t.special(t.variableName)], "constant", { italic: "italic" }),
token(t.labelName, "constant"),
token([t.variableName, t.definition(t.variableName), t.local(t.variableName)], "variable"),
@@ -46,9 +51,10 @@ export const openideaHighlightStyle = HighlightStyle.define([
{ tag: t.emphasis, fontStyle: "italic" },
{ tag: t.strong, fontWeight: "600" },
{ tag: t.strikethrough, textDecoration: "line-through" },
- token([t.link, t.url], "link", { effect: "underline" }),
+ // Markdown, as IntelliJ: link destination like a static method, rules like markers.
+ token(t.url, "function", { italic: "italic" }),
token(t.monospace, "markup-code"),
- token(t.quote, "comment"),
+ token(t.contentSeparator, "keyword"),
{ tag: t.inserted, color: "var(--vcs-added)" },
{ tag: t.deleted, color: "var(--danger)" },
{ tag: t.changed, color: "var(--vcs-modified)" },
diff --git a/src/editor/core/cm/languages.ts b/src/editor/core/cm/languages.ts
index b3c01bbbe..38b85220c 100644
--- a/src/editor/core/cm/languages.ts
+++ b/src/editor/core/cm/languages.ts
@@ -63,9 +63,25 @@ export function loadSupport(desc: LanguageDescription): Promise<LanguageSupport
return p;
}
-/** Highlighting the stock grammars lack (IntelliJ colours annotations; @lezer/java tags them as plain identifiers). */
+/**
+ * PyCharm CSS colours: selectors fall back to HTML tag name, property names to
+ * HTML attribute name, values and units to HTML attribute value.
+ */
+const CSS_TAGS: Parameters<typeof styleTags>[0] = {
+ "FeatureName PropertyName": t.attributeName,
+ "ValueName FontName Unit": t.attributeValue,
+ "ClassName IdName PseudoClassName ColorLiteral CallTag": t.tagName,
+};
+
+/** Highlighting the stock grammars lack or colour unlike IntelliJ. */
const EXTRA_TAGS: Record<string, Parameters<typeof styleTags>[0]> = {
+ // @lezer/java tags annotations as plain identifiers.
Java: { "MarkerAnnotation/Identifier Annotation/Identifier MarkerAnnotation Annotation": t.annotation },
+ CSS: CSS_TAGS,
+ SCSS: CSS_TAGS,
+ Sass: CSS_TAGS,
+ // YAML keys are keywords in IntelliJ.
+ YAML: { "Key/Literal Key/QuotedLiteral": t.keyword },
};
function patchSupport(desc: LanguageDescription, support: LanguageSupport): LanguageSupport {
diff --git a/src/styles/global.css b/src/styles/global.css
index 0be0ee87c..c45ece377 100644
--- a/src/styles/global.css
+++ b/src/styles/global.css
@@ -26,7 +26,8 @@ body {
font-family: var(--font-ui);
font-size: var(--fs-ui);
line-height: 1.4;
- -webkit-font-smoothing: antialiased;
+ /* Greyscale: `auto` keeps macOS stem darkening, as JetBrains IDEs render text. */
+ -webkit-font-smoothing: auto;
overflow: hidden;
-webkit-user-select: none;
user-select: none;
@@ -134,8 +135,9 @@ a:hover {
:root[data-aa-ide="none"] body {
-webkit-font-smoothing: none;
}
+/* `antialiased` drops stem darkening: glyphs and syntax colours render lighter than PyCharm's. */
:root[data-aa-editor="greyscale"] .cm-editor {
- -webkit-font-smoothing: antialiased;
+ -webkit-font-smoothing: auto;
}
:root[data-aa-editor="subpixel"] .cm-editor {
-webkit-font-smoothing: subpixel-antialiased;