Hello, I’m looking for the best way to add highlighting to a specific set of JS functions in CodeMirror 6. My initial thought was to try to create a custom LRLanguage based on @codemirror/lang-javascript
:
import { javascriptLanguage } from "@codemirror/lang-javascript"
import { styleTags, tags as t } from "@codemirror/highlight"
import { LRLanguage } from "@codemirror/language"
LRLanguage.define({
parser: javascriptLanguage.parser.configure({
props: [styleTags({ myCustomFunction: t.keyword })],
}),
languageData: javascriptLanguage.data,
})
…but this doesn’t seem to have any effect because javascriptLanguage
is still based on the underlying Lezer JS parser, and so adding a new keyword would require modifying that parser. Is there any way to accomplish this without forking the Lezer JS parser?