Skip to content

Commit b9ca095

Browse files
committed
Lezer based toml parsing
1 parent 3abfd73 commit b9ca095

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
},
1313
"dependencies": {
1414
"@codemirror/language": "^6.11.0",
15-
"@codemirror/legacy-modes": "^6.5.1",
1615
"@codemirror/state": "^6.5.2",
1716
"@codemirror/theme-one-dark": "^6.1.2",
1817
"@solid-primitives/deep": "^0.3.2",
1918
"@solidjs/router": "^0.15.3",
2019
"@tabler/icons-solidjs": "^3.31.0",
2120
"codemirror": "^6.0.1",
21+
"lezer-toml": "^1.0.0",
2222
"solid-js": "^1.9.5"
2323
}
2424
}

frontend/src/codemirror/toml.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { LRLanguage } from "@codemirror/language";
2+
import { parser } from "lezer-toml";
3+
4+
export const tomlHighlighting = LRLanguage.define({
5+
parser,
6+
languageData: {
7+
commentTokens: { line: "#" }
8+
}
9+
});

frontend/src/route/guild.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { StreamLanguage } from "@codemirror/language";
2-
import { toml } from "@codemirror/legacy-modes/mode/toml";
31
import { oneDark } from "@codemirror/theme-one-dark";
4-
import { minimalSetup } from "codemirror";
2+
import { basicSetup } from "codemirror";
3+
import { tomlHighlighting as tomlLanguage } from "../codemirror/toml";
54
import { CodeMirror } from "../component/common/CodeMirror";
65
import { LoginGate } from "../component/LoginGate";
76

@@ -21,7 +20,7 @@ reply = true
2120
groups_command = true
2221
help_command = true
2322
`;
24-
const extensions = [minimalSetup, oneDark, StreamLanguage.define(toml)];
23+
const extensions = [basicSetup, oneDark, tomlLanguage];
2524
return (
2625
<div>
2726
<CodeMirror value={config} extensions={extensions} />

0 commit comments

Comments
 (0)