CodeMirror supports many languages, and language scripts are called Modes. I tried the MySQL mode but… well, to be honest, I didn’t like it. Maybe I am not lucky, but the first statements I wrote (
TRUNCATE) were not highlighted. Also, floating point numbers were not highlighted.
So, I wrote a new mode and put it on GitHub: MariaDB: https://github.com/santec/mariadb-mode-for-CodeMirror.
First, I re-worked the code. Now it’s in Strict Mode, and it uses types more strictly. Then, I fixed a couple of minor bugs in MySQL mode: ‘–‘ comments did not require a space, and backticks could be escaped in identifiers with a ‘\’.
Then, I added something:
* a lot of new keywords from MySQL and MariaDB;
* float numbers (including esponents)
* variables (all syntaxes);
* bin and hex (all syntaxes);
* all types of comments;
* ‘?’ (for prepared statements).
Limitations? Well, it does not support automatic indentation, and many other features that maybe should be supported. However, I just wrote this mode to improve a tool I use. I may improve it if there is interest around it, but I will not work on it if I’m not sure it makes sense.
If you use MariaDB Mode and you have some comments/requests, let me know. If you improve it, please do a Pull Request on GitHub repo.