Topics

Sublime Text syntax highlighting

Devin Nusbaum
 

I've created a simple syntax definition for Stanza for Sublime Text, available at https://github.com/dwnusbaum/stanza-syntax. It has plenty of rough edges, but it's been working well for me so far.

Note: Although the installation instructions mention package control, I'm still waiting for it to be added to the official package control repository, so you'll have to install it manually.

Thanks,

Devin

 

That's great. We have a couple of guys here at Berkeley using Sublime and they've been lamenting the lack of a Sublime definition.


Thanks!

 -Patrick

 

Great to see more editor support!

Sublime Text follows the same tradition as Atom in using the TextMate language definition format. Sublime even directly supports .tmLanguage files iirc. Sublime uses the same backing regex engine too (oniguruma). With that in mind, you might be able to glean a fair bit of useful regexes from my Atom language-stanza package. I have no experience with Sublime Text but tons with Atom language support and language definitions in general so shoot me an email if you have any questions!

Jake

Devin Nusbaum
 

Nice! I didn’t realize Atom also used the TextMate language definition format. it’s interesting to see what we each chose to highlight.

Have you come up with a good way to highlight LoStanza constructs without also highlighting them in regular Stanza? I find it difficult to do well with the .tmlanguage format. Sublime Text 3 has a new context based .sublime-syntax format that is more powerful, which I think will make it possible to highlight LoStanza really nicely.

On Jun 26, 2016, at 9:54 AM, Jake Russo <madcap.russo@...> wrote:

Great to see more editor support!

Sublime Text follows the same tradition as Atom in using the TextMate language definition format. Sublime even directly supports .tmLanguage files iirc. Sublime uses the same backing regex engine too (oniguruma). With that in mind, you might be able to glean a fair bit of useful regexes from my Atom language-stanza package. I have no experience with Sublime Text but tons with Atom language support and language definitions in general so shoot me an email if you have any questions!

Jake

 

Hehe, that was incredibly challenging and ended up proving unfruitful. I tried numerous things and arrived at a variety of broken implementations. Here is my last commented-out attempt. I decided that users would just have to be diligent in their coding. It's my least favorite thing to do as I feel this is the area where syntax-highlighting is most useful but I couldn't find a good-enough solution. Please due share if you come up with something and I'm interested to hear how you do with the new ST3 format.

In fact, this is why I am also working on Howl support because I very nearly have a working solution that even provides special background highlighting to indicate that you are in a lostanza block. They out-of-the-box have a scan-through-indent pattern and though it isn't completely there yet, the developers are working to add a special sub-lexing construct for this type of internal block-delimited sub-language. I'll report back in the howl-stanza-bundle thread when that lands.

 

Actually, after some reading of other Atom language packages, I found one that had the regex I needed: language-haml.

^(?!\\1\\s+|\\n)

This little regex as an end pattern properly captures empty lines and de-indentation (of course, you need to capture the initial indentation for \\1 to work). I've already implemented it in my Atom package and it works great! I've also added another novel use for it: this inside new Type : blocks.