onivim / oni2

Native, lightweight modal code editor
https://v2.onivim.io
MIT License
7.83k stars 281 forks source link

Support non-JSON Textmate Grammars and Themes #912

Closed CrossR closed 4 years ago

CrossR commented 4 years ago

We currently support JSON textmate grammars and themes, but there are technically XML based ones:

https://github.com/JustusAdam/language-haskell/blob/master/syntaxes/haskell.tmLanguage

This (as far as I can tell) is the only/most used Haskell grammar for code, and its written in XML.

If reason-textmate was able to load an XML file and convert it into JSON, then parse that JSON file, we should be okay.

I found a random converter online whilst looking (http://json2plist.sinaapp.com/) and doing that on that file and saving it as JSON did seem to work (though there was some odd highlighting for comments, but that could be unrelated, or a bad conversion), so programmatically doing that conversion should be all we need.

I've raised this here, but its more of a reason-textmate issue, and if fixed there I think could be an invisible change on the Oni2 side.

CrossR commented 4 years ago

(For some context of why XML was used, and also to make sure these comments are ignored in any conversion, as we can't support comments in JSON: https://github.com/JustusAdam/language-haskell/pull/63)

glennsl commented 4 years ago

There are XML themes as well, so I added that to the title and post.

Example: https://github.com/glennsl/vscode-duotone-dark-faithful/blob/master/themes/Earth.tmTheme

Converting to JSON makes it not crash, but still don't apply any colors. It's all just black and white.

While we wait for full support, it might also be an idea to display an error message instead of just crashing.