дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
feat(editor): colour global variables (the semantic global modifier) (#1393)
lua-language-server marks globals with the `global` token modifier, but the editor dropped it, so a global variable looked like a local unless rainbow highlighting was on. The modifier now sets `cm-sem-global`, drawn in a new Language Defaults › Identifiers › Global variable colour (`--syn-global`): library globals keep the predefined colour and calls the function-call colour. Imported IntelliJ themes and .icls schemes take it from DEFAULT_GLOBAL_VARIABLE. Built-in schemes default it to the local variable colour (IntelliJ's fallback for the key), so they look as before until a scheme sets it. Fixes #1370
Цей коміт міститься в:
1 джерело
8d784ac164
коміт
d5c4066748
8 files changed
+33
No files matched your search
@@ -44,6 +44,18 @@ describe("semanticRanges", () => {
|
||||
expect(semanticRanges(doc, input)).toEqual([{ from: 0, to: 3, className: "cm-sem-function" }]);
|
||||
});
|
||||
|
||||
it("marks globals (lua-language-server's `global` modifier)", () => {
|
||||
const input = {
|
||||
tokenTypes: ["variable", "function"],
|
||||
tokenModifiers: ["global"],
|
||||
data: [0, 0, 3, 0, 1, 0, 4, 3, 1, 1],
|
||||
};
|
||||
expect(semanticRanges(doc, input)).toEqual([
|
||||
{ from: 0, to: 3, className: "cm-sem-global" },
|
||||
{ from: 4, to: 7, className: "cm-sem-function cm-sem-global" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("colours a constructor (jdtls: class + `constructor`) as a function", () => {
|
||||
const input = { tokenTypes: ["class"], tokenModifiers: ["constructor", "declaration"], data: [0, 0, 3, 0, 0b11] };
|
||||
expect(semanticRanges(doc, input)[0]?.className).toBe("cm-sem-function cm-sem-declaration");
|
||||
|
||||
@@ -56,6 +56,7 @@ const MODIFIER_CLASS: Record<string, string> = {
|
||||
declaration: "declaration",
|
||||
definition: "declaration",
|
||||
defaultLibrary: "builtin",
|
||||
global: "global",
|
||||
};
|
||||
|
||||
/** Number of `--syn-rainbow-<n>` colours (IDEA's five semantic highlighting colours). */
|
||||
|
||||
@@ -361,6 +361,8 @@ export const lspTheme = EditorView.theme({
|
||||
".cm-sem-parameter": { color: "var(--syn-param, var(--syn-variable))" },
|
||||
".cm-sem-self": { color: "var(--syn-self, var(--syn-keyword))" },
|
||||
".cm-sem-keyword": { color: "var(--syn-keyword)", fontWeight: "var(--syn-keyword-bold, inherit)" },
|
||||
// Before the builtin rule: library globals (`print`, `string`) keep the predefined colour.
|
||||
".cm-sem-global:not(.cm-sem-function)": { color: "var(--syn-global, inherit)" },
|
||||
".cm-sem-builtin:not(.cm-sem-function)": { color: "var(--syn-builtin, inherit)" },
|
||||
".cm-sem-static": { fontStyle: "var(--syn-static-italic, italic)" },
|
||||
".cm-sem-python-static": { fontStyle: "var(--syn-python-static-italic, normal)" },
|
||||
|
||||
Reference in new issue
Заблокувати користувача