Stream: beginners

Topic: Syntax Highlighting on GitHub


view this post on Zulip Ryan Bates (Dec 11 2023 at 22:07):

It would be really nice if syntax highlighting were supported on GitHub while browsing people's Roc code, especially for beginners who are still grasping the language.

Do you think the language is in a stable enough state to submit a PR for syntax highlighting? There are instructions here.

view this post on Zulip Ryan Bates (Dec 11 2023 at 22:16):

Looking into it more, I don't think the grammar file is hosted there, it just links to another repo. This means you could update the grammar as the language changes without needing to submit a PR.

Is there anything else holding Roc back from submitting syntax highlighting PR to GitHub?

view this post on Zulip Elias Mulhall (Dec 11 2023 at 22:21):

This came up not too long ago, there's general interest but no one has taken initiative yet, as far as I know!
https://roc.zulipchat.com/#narrow/stream/395097-compiler-development/topic/github.20syntax.20highlighting

view this post on Zulip Ryan Bates (Dec 11 2023 at 22:24):

Thanks that's a recent discussion too. My Zulip search-fu has failed.

The grammar should probably be added under roc-lang on GitHub.

view this post on Zulip Richard Feldman (Dec 11 2023 at 22:38):

yeah the only thing missing at this point is a volunteer to submit the PR to GitHub! :smiley:

view this post on Zulip Ryan Bates (Dec 11 2023 at 22:55):

Is there an official grammar file to use?

view this post on Zulip Richard Feldman (Dec 11 2023 at 23:03):

no, but I think as a starting point there's a TextMate grammar in the vs code extension

view this post on Zulip Richard Feldman (Dec 11 2023 at 23:04):

I'm on mobile but it's the one by @Ivan Demchenko

view this post on Zulip Ryan Bates (Dec 11 2023 at 23:48):

Looks like releases go out every few months and we just missed the latest one so there's no rush in doing this.

I might try to submit a PR over the next month when I find some time, but of course someone else is welcome to do it.

view this post on Zulip Ryan Bates (Dec 11 2023 at 23:56):

Actually looks like it’s being deployed tomorrow morning so if someone submits a PR tonight there’s a chance it could be included. Not certain though.

view this post on Zulip Ryan Bates (Dec 12 2023 at 00:45):

@Richard Feldman you mentioned in the other thread you want \(foo) to handle syntax highlighting correctly within the embed? Looks like the current grammar doesn't do this so we'd need to modify it. I have some experience with TextMate grammars and might be able to do this but doubt I could get to it tonight.

Also since the GitHub repo is linked we should put this under roc-lang user so it's official.

view this post on Zulip Richard Feldman (Dec 12 2023 at 00:46):

agreed, much much better to have something in there than nothing!

view this post on Zulip Richard Feldman (Dec 12 2023 at 00:46):

if you could get a PR in under the wire that would be amazing! :smiley:

view this post on Zulip Ryan Bates (Dec 12 2023 at 01:12):

Uncertain if I will get to it tonight but will look into it after kids go to bed. :wink:

view this post on Zulip Ryan Bates (Dec 12 2023 at 05:39):

I added a pull request here. We'll see what they say.

view this post on Zulip Johan Lindskogen (Dec 12 2023 at 12:43):

they weren't convinced, it seems

view this post on Zulip Anton (Dec 12 2023 at 13:03):

Well, the provided examples where indeed not real-world examples.

view this post on Zulip LoipesMas (Dec 12 2023 at 13:10):

Maybe roc-parser would be a good example? It's not "official" and is actually used, not just a toy-project/example

view this post on Zulip Anton (Dec 12 2023 at 13:16):

Yeah, roc-pg could be good as well

view this post on Zulip Agus Zubiaga (Dec 12 2023 at 13:20):

I wonder what do they mean exactly by real world? Do packages count? Maybe AoC? monkey-roc?

view this post on Zulip Richard Feldman (Dec 12 2023 at 13:25):

roc-parser, roc-pg, and monkey-roc all seem like good examples! :thumbs_up:

view this post on Zulip Richard Feldman (Dec 12 2023 at 13:25):

could also do roc-iso8601

view this post on Zulip Richard Feldman (Dec 12 2023 at 13:26):

also https://github.com/ThePrimeagen/ts-rust-zig-deez/blob/3441b21d30a8d8488f2bec85cef4f9054891e9ea/roc/src/Eval.roc

view this post on Zulip Ryan Bates (Dec 12 2023 at 15:15):

Sorry about that guys. I assumed they had to be single file examples that could compile on their own which is what most other samples are I saw. Hmm.

view this post on Zulip Anton (Dec 12 2023 at 15:18):

Don't sweat it :)

view this post on Zulip Richard Feldman (Dec 12 2023 at 15:25):

yeah no worries! It's actually great that the only feedback was about the samples because that's a pretty quick fix now that we have a few in this thread :smiley:

view this post on Zulip Richard Feldman (Dec 12 2023 at 15:25):

hopefully that can turn into a quick merge and then we'll be in with the next batch!

view this post on Zulip Brendan Hansknecht (Dec 12 2023 at 15:37):

Our Dict.roc file might be good too

view this post on Zulip Brendan Hansknecht (Dec 12 2023 at 15:38):

It is a full implementation of something used in production at multiple places.

view this post on Zulip Richard Feldman (Dec 12 2023 at 15:39):

from the comment it sounds like they're specifically looking for examples outside the official language repos

view this post on Zulip Brendan Hansknecht (Dec 12 2023 at 15:39):

Makes sense

view this post on Zulip Ryan Bates (Dec 12 2023 at 17:45):

@Brendan Hansknecht what is the license of Eval.roc? Are you fine with UPL?

view this post on Zulip Brendan Hansknecht (Dec 12 2023 at 17:46):

Yeah. Go for it

view this post on Zulip Ryan Bates (Dec 12 2023 at 18:13):

I’ve updated the samples. We'll see if it goes through.

view this post on Zulip Ryan Bates (Dec 20 2023 at 19:26):

Most of the samples are too big now. https://github.com/github-linguist/linguist/pull/6633#pullrequestreview-1790721040

I'll probably grab a few smaller interface files of roc-pg and see if that goes through.

view this post on Zulip Luke Boswell (Jan 29 2024 at 09:33):

@Ryan Bates any updates on GH syntax highlighting? Is there anything we should prepare for the next drop? I'm not sure if you're still tracking this, but it would be super to work towards this :smiley:

view this post on Zulip Eli Dowling (Jan 30 2024 at 05:16):

Oh also, can we use a tree-sitter grammar? That will provide more accurate highlighting and a bunch of nice extras like showing symbols in the same file.
https://github.com/faldor20/tree-sitter-roc

view this post on Zulip Eli Dowling (Jan 30 2024 at 08:40):

Well i got a firm no-can-do from github on that one. Tree-sitter is it's own thing outside of linguist and we are far too obscure to get integrated into that

view this post on Zulip Brendan Hansknecht (Jan 30 2024 at 16:10):

Who controls its integration?

view this post on Zulip Ryan Bates (Feb 04 2024 at 01:37):

I updated the code samples to meet their requirements. Just waiting on them to approve now.

view this post on Zulip Hristo (Mar 08 2024 at 16:44):

Merged 22 mins ago!:partying_face:

view this post on Zulip Anton (Mar 08 2024 at 16:47):

Thanks for the sustained effort @Ryan Bates :heart:

view this post on Zulip Ryan Bates (Mar 08 2024 at 17:34):

Nice! Looking forward to seeing it live on GitHub.

view this post on Zulip Anton (Mar 08 2024 at 17:39):

Me too :)

view this post on Zulip Richard Feldman (Mar 08 2024 at 18:08):

amazing!!! Thank you so much to everyone who helped get this in! :heart_eyes:

view this post on Zulip Fabian Schmalzried (Mar 14 2024 at 11:41):

Looks like it is live. :tada:

view this post on Zulip Isaac Van Doren (Mar 15 2024 at 22:11):

It is so fun to see Roc in the breakdown of languages in a github repo :star_struck:

view this post on Zulip Anton (Mar 16 2024 at 09:43):

It's even using the Roc purple color :)

view this post on Zulip Luke Boswell (Apr 30 2024 at 10:34):

Just noticed the following edge case doesn't look like right on GH syntax highlighting. It's the unicode string interpolation syntax which I guess is a bit different and probably needs special handling.

Or maybe this is doing what it should, and is just a color thing?

Screenshot-2024-04-30-at-20.32.24.png

https://github.com/roc-lang/basic-cli/blob/c5b18624aa4f8a50690f2f6703f688ca85311925/build.roc#L144

view this post on Zulip Anton (Apr 30 2024 at 10:48):

Or maybe this is doing what it should, and is just a color thing?

It could be a security feature, to alert people that once printed it may look deceptively similar to a normal character.

view this post on Zulip Hristo (Apr 30 2024 at 11:17):

I noticed the same in one of my PRs and I thought it was expected behaviour, too, but definitely a good point bringing it up just in case!

view this post on Zulip Kiryl Dziamura (Jun 27 2024 at 08:03):

It's such a pleasure to start code snippets with ```roc :big_smile:
image.png


Last updated: Jul 05 2025 at 12:14 UTC