mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-14 16:07:52 +00:00
Go files showed no semantic colours because gopls semantic tokens were not requested, and Color Scheme had no Go page. gopls is now initialised with semantic tokens, constants, package variables and package references get Go-specific roles, and Color Scheme has a Go page with a preview. Siblings covered: Go-specific attributes inherit from Language Defaults, Reset restores them, Chinese labels show in the Color Scheme tree, and a user's own gopls settings are kept. Co-authored-by: shohruh-genius <7658451+shohruh-genius@users.noreply.github.com>
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
import { EditorView } from "@codemirror/view";
|
|
import { syntaxHighlighting } from "@codemirror/language";
|
|
import { commands } from "../src/platform/ipc";
|
|
import { setInvokeRoute } from "../src/platform/tauriCore";
|
|
import { schemeCss } from "../src/platform/colorScheme";
|
|
import { openideaHighlightStyle } from "../src/editor/core/cm/highlight";
|
|
import { findLanguageDescription, loadSupport } from "../src/editor/core/cm/languages";
|
|
import { lspDoc } from "../src/editor/lsp/lsp";
|
|
import { semanticExtension } from "../src/editor/lsp/semantic";
|
|
import { lspTheme } from "../src/editor/lsp/theme";
|
|
|
|
setInvokeRoute(() => null);
|
|
commands.lspSemanticTokens = async () => ({
|
|
status: "ok",
|
|
data: {
|
|
tokenTypes: ["variable", "namespace", "function"],
|
|
tokenModifiers: ["readonly", "static", "declaration", "deprecated"],
|
|
data: [0, 6, 5, 0, 1, 1, 4, 6, 0, 2, 2, 0, 3, 1, 0, 3, 5, 5, 2, 14],
|
|
},
|
|
});
|
|
const style = document.createElement("style");
|
|
style.textContent = schemeCss("dark", {
|
|
dark: {
|
|
"go.constant": { foreground: "#224466" },
|
|
"go.globalVariable": { foreground: "#335577" },
|
|
},
|
|
});
|
|
document.head.append(style);
|
|
const host = document.createElement("section");
|
|
host.dataset.language = "Go";
|
|
document.body.append(host);
|
|
const support = await loadSupport(findLanguageDescription("Go", "demo.go")!);
|
|
new EditorView({
|
|
parent: host,
|
|
doc: "const Limit = 3\nvar Global = 1\nfmt.Println(Global)\nfunc Greet() {}",
|
|
extensions: [
|
|
support!,
|
|
syntaxHighlighting(openideaHighlightStyle),
|
|
lspTheme,
|
|
lspDoc.of({ doc: 1, path: "demo.go", language: "go", uiMode: "Go", readOnly: false }),
|
|
semanticExtension(),
|
|
],
|
|
});
|