It doesn’t look like MoonScript has an existing CodeMirror 6 plugin for dynamic syntax highlighting inside the web editor. Is this something the maintainers are interested in pursuing? I can’t commit to such an effort since I’m a complete novice (everybody has to start somewhere). I’m doing some initial poking at something similar for the Pyret track though.
This is noted on the launch issue.
I too have not done any highlighting stuff. Moonscript does have highlight-js, and I wonder if that would be helpful at all for doing codemirror.
I think it’d be useful as a conceptual reference in the same way there’s prior art for Pyret syntax highlighting that indicates the language grammar and its key words. Highlight.js is for a single parsing pass over static code and CodeMirror reparses on demand. So they must operate pretty differently at a technical level, but you could at least get inspiration from looking at the existing Highlight.js grammar.
If I recall correctly, Jeremy said Code Mirror 5 and 6 were different architectures so a Code Mirror 5 mode would need some finessing. It looks like the Code Mirror team includes that Lua support in the official backports at GitHub - codemirror/legacy-modes: Collection of ported legacy language modes for the CodeMirror code editor · GitHub. I’ll play around with it later this month and see how well it displays our Exercism example solutions. If not, my thought is that it might be a solid base for building out a Code Mirror mode specifically for Moon Script.
Whatever Code Mirror module the Lua track is using will work pretty well. Copying and pasting example MoonScript solutions into the online editor for the Lua track shows a few keywords don’t get tagged properly (below). That’s probably fine for our purposes because at least they’re getting highlighted non-obtrusively.
class
continue
extends
import
from
switch
super
unless
when
with
It looks like the staff just needs to add a case 'moonscript': line above the Lua one in website/app/javascript/components/misc/CodeMirror/languageCompartment.ts at 66d35f7c48aecf3083c992b680cf1bd1fdb5fddd · exercism/website · GitHub