moo
moo copied to clipboard
Random idea: plugin to serialize moo lexers to syntax plugins for various editors
I did some looking and couldn't find a tool that generated syntax highlighting plugins for Emacs/Vim/TextMate/CodeMirror/Atom/your-favorite-editor-here. It would be neat if you could take an existing moo lexer, maybe add some config, and suddenly get plugins for a bunch of editors.
Based on some quick reading, most editors have a similar format for specifying syntaxes. But there are a few gotchas that might make this infeasible (e.g. Vim doesn't support states as far as I can tell, whereas Emacs has a messy special-cased configuration for multiline comments/strings).
I found this recently: https://eeyo.io/iro/
I'm going through this exercise now, manually converting a moo-based lexer into a textmate grammar - and it does not appear that this is something you could automate. The textmate grammars don't just tokenize, but they also need the grammar rules e.g. your mylang.ne
file if using nearley.js
Take a look at this javascript textmate grammar for vscode 😳 https://github.com/microsoft/vscode-textmate/blob/main/benchmark/JavaScript.tmLanguage.json