From 1cc661576ad3318cf8309527a8ac4a5f5ef32fee Mon Sep 17 00:00:00 2001 From: Matthew Meyers Date: Sat, 29 Oct 2022 10:55:20 -0700 Subject: [PATCH] feat: enable syntax highlighting in cm6 (#889) --- package.json | 1 + src/editor/Editor.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/package.json b/package.json index e11ebca3..04fce0fa 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "dependencies": { "@codemirror/state": "^6.1.1", "@codemirror/view": "^6.2.3", + "@codemirror/language": "https://github.com/lishid/cm-language", "@popperjs/core": "^2.11.2", "child_process": "^1.0.2", "eta": "github:SilentVoid13/eta#custom-eta" diff --git a/src/editor/Editor.ts b/src/editor/Editor.ts index 9493e7f5..49f59479 100644 --- a/src/editor/Editor.ts +++ b/src/editor/Editor.ts @@ -8,6 +8,7 @@ import { Autocomplete } from "editor/Autocomplete"; import "editor/mode/javascript"; import "editor/mode/custom_overlay"; +import { StreamLanguage } from "@codemirror/language"; //import "editor/mode/show-hint"; const TP_CMD_TOKEN_CLASS = "templater-command"; @@ -30,6 +31,9 @@ export class Editor { async setup(): Promise { await this.registerCodeMirrorMode(); this.plugin.registerEditorSuggest(new Autocomplete(app)); + this.plugin.registerEditorExtension( + StreamLanguage.define(window.CodeMirror.getMode({}, { name: 'templater' }) as any) + ) } async jump_to_next_cursor_location(