Skip to content

Commit

Permalink
Add variations of GDScript casing for syntax identifier. Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTheFiveNine committed Jun 14, 2024
1 parent f318633 commit e647d71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"isDesktopOnly": false,
"minAppVersion": "1.5.12",
"name": "GDScript Syntax Highlighting",
"version": "1.0.2"
"version": "1.0.3"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "obsidian-gdscript",
"description": "Adds live GDScript syntax highlighting to code blocks in the Obsidian editor.",
"main": "src/main.js",
"version": "1.0.2",
"version": "1.0.3",
"author": "RobTheFiveNine",
"type": "module",
"repository": {
Expand Down
10 changes: 8 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class GdscriptSyntaxPlugin extends Plugin {
// onload, so continue to try and define the language until it is.
const setupInterval = setInterval(() => {
if (CodeMirror && CodeMirror.defineSimpleMode) {
CodeMirror.defineSimpleMode("gdscript", {
const mode = {
start: [
{ regex: /\b0x[0-9a-f]+\b/i, token: "number" },
{ regex: /\b-?\d+\b/, token: "number" },
Expand Down Expand Up @@ -37,7 +37,11 @@ export default class GdscriptSyntaxPlugin extends Plugin {
definition: [
{ regex: /(\w+)/, token: "attribute", pop: true }
]
})
};

CodeMirror.defineSimpleMode('gdscript', mode);
CodeMirror.defineSimpleMode('GDScript', mode);
CodeMirror.defineSimpleMode('GDscript', mode);

self.app.workspace.iterateAllLeaves((leaf) => {
leaf.rebuildView();
Expand All @@ -50,5 +54,7 @@ export default class GdscriptSyntaxPlugin extends Plugin {

onunload() {
delete CodeMirror.modes['gdscript'];
delete CodeMirror.modes['GDScript'];
delete CodeMirror.modes['GDscript'];
}
}

0 comments on commit e647d71

Please sign in to comment.