Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
thememirror and syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeattie committed Jul 4, 2024
1 parent 2eacf17 commit bc24624
Show file tree
Hide file tree
Showing 7 changed files with 1,073 additions and 28 deletions.
12 changes: 6 additions & 6 deletions .obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,17 @@
},
"active": "af9edaf1541aa592",
"lastOpenFiles": [
"codemirror-lang-rockstar/pnpm-lock.yaml.3042434986",
"codemirror-lang-rockstar/_tmp_46436_89968ddaabae1b280b8a0168b939c989",
"codemirror-lang-rockstar/package.json.902345379",
"codemirror-lang-rockstar/pnpm-lock.yaml.3146977705",
"codemirror-lang-rockstar/_tmp_10912_1fe8be06afbd0bb33b1e1728551a1d95",
"codemirror-lang-rockstar/src/highlight.js",
"codewithrockstar.com/_site/wasm/wwwroot/framework/System.Text.RegularExpressions.wasm.gz",
"codewithrockstar.com/_site/wasm/wwwroot/framework/System.Text.RegularExpressions.wasm.br",
"codewithrockstar.com/_site/wasm/wwwroot/framework/System.Text.RegularExpressions.wasm",
"codewithrockstar.com/_site/wasm/wwwroot/framework/System.Runtime.wasm.gz",
"codewithrockstar.com/_site/wasm/wwwroot/framework/System.Runtime.wasm.br",
"codewithrockstar.com/_site/wasm/wwwroot/framework/System.Runtime.wasm",
"codewithrockstar.com/_site/wasm/wwwroot/framework/System.Runtime.InteropServices.wasm.gz",
"codewithrockstar.com/_site/wasm/wwwroot/framework/System.Runtime.InteropServices.wasm.br",
"codewithrockstar.com/_site/wasm/wwwroot/framework/System.Runtime.InteropServices.wasm",
"codewithrockstar.com/_site/wasm/wwwroot/framework/System.Runtime.InteropServices.JavaScript.wasm.gz",
"codewithrockstar.com/_site/wasm/wwwroot/framework/System.Runtime.InteropServices.JavaScript.wasm.br",
"codewithrockstar.com/getting-started.md",
"codewithrockstar.com/index copy.md"
]
Expand Down
11 changes: 6 additions & 5 deletions codemirror-lang-rockstar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@
"types": "dist/rockstar.d.ts",
"sideEffects": false,
"dependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@codemirror/autocomplete": "^6.17.0",
"@codemirror/autocomplete": "^6.17.0",
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0",
"codemirror": "^6.0.1"
"codemirror": "^6.0.1",
"thememirror": "^2.0.1"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.3",
"@lezer/generator": "^1.0.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"mocha": "^9.0.1",
"rollup": "^2.60.2",
"rollup-plugin-dts": "^4.0.1",
Expand Down
16 changes: 16 additions & 0 deletions codemirror-lang-rockstar/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions codemirror-lang-rockstar/src/codemirror-lang-rockstar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {parser} from "./rockstar.grammar"
import {LRLanguage, LanguageSupport, indentNodeProp, foldNodeProp, foldInside, delimitedIndent} from "@codemirror/language"
import {styleTags, tags as t} from "@lezer/highlight"
// import {styleTags, tags as t} from "@lezer/highlight"
import { completeFromList } from "@codemirror/autocomplete"

export const RockstarLanguage = LRLanguage.define({
Expand All @@ -12,13 +12,13 @@ export const RockstarLanguage = LRLanguage.define({
foldNodeProp.add({
Application: foldInside
}),
styleTags({
Identifier: t.variableName,
Boolean: t.bool,
String: t.string,
Comment: t.comment,
"( )": t.paren
})
// styleTags({
// Identifier: t.variableName,
// Boolean: t.bool,
// String: t.string,
// Comment: t.comment,
// "( )": t.paren
// })
]
}),
languageData: {
Expand Down
3 changes: 2 additions & 1 deletion codemirror-lang-rockstar/src/rockstar-editor.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { EditorView, basicSetup } from "codemirror"
import { Rockstar } from "./codemirror-lang-rockstar.ts"
import {coolGlow} from 'thememirror';

export function replaceElementWithEditor(element, RunRockstarProgram) {
let view = new EditorView({
doc: element.innerText,
extensions: [basicSetup, Rockstar()],
extensions: [basicSetup, coolGlow, Rockstar()],
});
element.parentNode.insertBefore(view.dom, element);
let button = document.createElement("button");
Expand Down
2 changes: 2 additions & 0 deletions codemirror-lang-rockstar/src/rockstar.grammar
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@external propSource highlighting from "./highlight.js"

@top Program { expression* }

@skip { space | Comment }
Expand Down
Loading

0 comments on commit bc24624

Please sign in to comment.