style(代码配色): printf 里的 %d、%.2f 和 Python f-string 的 { } 有了自己的颜色;Python 的 from / as / with 和 import 一个颜色,跟 VS Code 一样

lezer 把整个字符串当一个词,占位符另外扫一遍(shared/formatPlaceholder.ts),编辑器挂装饰、
静态代码拆 span,用同一份正则。Python 解析器补了几条 styleTags,编辑器和静态代码共用。
CodeEditor.vue 原来自己抄了一份语言选择,改成用 languageExtension。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-13 20:18:29 +08:00
1 parent a559af0aa9
commit 3b04afc275
6 files changed
+134 -14

No files matched your search

@@ -1,7 +1,4 @@
<script lang="ts" setup>
import { cpp } from "@codemirror/lang-cpp"
import { python } from "@codemirror/lang-python"
import { sql, SQLite } from "@codemirror/lang-sql"
import { bracketMatching } from "@codemirror/language"
import CodeMirror from "./CodeMirror.vue"
import type { Extension } from "@codemirror/state"
@@ -10,6 +7,7 @@ import type { LANGUAGE } from "utils/types"
import { darkCodeTheme, lightCodeTheme } from "../themes/codeTheme"
import { styleTheme } from "shared/extensions/baseTheme"
import { enhanceCompletion } from "shared/extensions/autocompletion"
import { languageExtension } from "shared/extensions/language"
interface Props {
language?: LANGUAGE
@@ -33,10 +31,7 @@ const code = defineModel<string>("value")
const isDark = useDark()
const langExtension = computed(() => {
if (language === "SQL") return sql({ dialect: SQLite, upperCaseKeywords: true })
return language === "Python" ? python() : cpp()
})
const langExtension = computed(() => languageExtension(language))
const extensions = computed(() => [
styleTheme,