Automatic conversion of language files from Visual Studio Code to Nova...?

A few of the language plugins on the Library mention that they have been converted from Visual Studio Code. I wonder if someone did an automatic convertor? As far as I can see (I never designed syntax files for VS Code), Microsoft prefers very wordy JSON to Panic’s compact XML — but there are clear similarities, namely, in the way expressions are matched. Sure, there are many conceptual differences, but a few are merely a question of using different names for concepts, adding a bit more candy and flashbangs, and so forth.

Even taking into consideration that Nova’s syntax highlighter is pretty much a full-blown language parser and that any automatic conversion from VS Code would require a lot of manual labour to ‘get it right’, I wonder if anyone created an automatic conversion mechanism (using whatever tool… so long as it runs on a Mac, I’m good :slight_smile: ) and is willing to share their code with us poor souls who spend all our time head-banging against the Mac’s screen, painfully writing line by line, just to see if we finally managed Nova to highlight the right things…

Or should I assume that those who claim that they have ‘converted’ syntax files from VS Code they’re merely saying that they were ‘inspired’ by those files to create something pretty much from scratch for Nova?

(As a side-note, Nova would certainly benefit from such an automatic conversion tool, even if it had very poor and limited functionality — but it would be ‘better than nothing’)

3 Likes

Hi Gwyneth!

Sorry it’s taken so long for me to answer this—I’ve been out for a bit.

We’ve definitely considered writing some some tool to allow converting language grammars between the popular formats, even just as a starting point (as you mention), but so far the time hasn’t come up to be able to build one out and give it some reasonable testing.

I hope to be able to reinvestigate some things like this at some point soon, so we’ll see!

Logan

2 Likes

Hey there! I know it’s been quite a while, but the other day I was searching for some info to update one of my language extensions, and by sheer chance, I stumbled upon a TextMate syntax highlighting file. Now, I’m not familiar with TextMate — much less with its syntax highlighting templates — but as far as I can see, Nova’s own syntax rules are very clearly inspired on TextMate’s! There are a few notable differences — namely, on the metadata — but many more overall similarities. Granted, these days, it seems that TextMate prefers JSON grammar files, but they still support the so-called plist format (which is XML)

It’s worth taking a look at the possibility of converting templates from TextMate, and possibly vice-versa — because VS Code imports TextMate templates directly (both JSON and XML), and so does Sublime Text, and apparently a few others as well.

It looks like the guys over at MacroMates have been defining a ‘universal’ syntax/grammar ruleset for syntax highlighting, and most of the high-end code editors are supporting these — either directly, or through some sort of conversion tool (sometimes built-in). They also have great documentation, btw. Some of the more obscure aspects of their specifications also apply to Nova’s language files, and finally I understood how these work (I haven’t played with them yet, though…).

I’ve not looked very deep into this, but it looks promising enough to create some sort of conversion mechanism or stand-alone tool that can work with ‘compatible’ language files. Maybe it could even be possible to create a Nova plugin that automatically converts between compatible language files and Nova’s own! :smile_cat:

Oh, and I also found an online colour-assignment tool that works with TextMate (and possibly Sublime Text as well): https://tmtheme-editor.herokuapp.com/#!/editor/theme/Nocturnal. This s just basic ‘theming’ in the sense of assigning colours to parsed tokens, but I can imagine that it could be useful for some developers…

2 Likes

See this forum thread.