Ross-Esmond / code-fns

MIT License
5 stars 2 forks source link

Define Custom Grammar #28

Open WireWhiz opened 1 year ago

WireWhiz commented 1 year ago

Hello, I'm currently using Motion Canvas to make a devlog for a custom scripting language that I'm working on, and I was able to figure out that this is the plugin it's using for it's code highlighting.

I was wondering, is there is currently a way to define custom grammar/new languages?

Ross-Esmond commented 1 year ago

Not at the moment, no. You would have to create a starry-night grammar or something. MC should probably have a way to highlight text manually, but a whole grammar is going to be hard no matter what you do.

The plan is to switch to CodeMirror and to include Lezer for languages that are supported by Lezer. At that point you could write a Lezer grammar, but the switch is going slowly.

WireWhiz commented 1 year ago

Ok, for the meantime I might look into a custom solution. Looks like antlr4 (which is what I'm using for parsing the language) has a typescript runtime that I might be able to use. Copy over the code I'm using for highlighting of tokens on the lsp server implementation and convert it to TS. Should get me most of the way there.