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.
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?
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
Thanks that's a recent discussion too. My Zulip search-fu has failed.
The grammar should probably be added under roc-lang on GitHub.
yeah the only thing missing at this point is a volunteer to submit the PR to GitHub! :smiley:
Is there an official grammar file to use?
no, but I think as a starting point there's a TextMate grammar in the vs code extension
I'm on mobile but it's the one by @Ivan Demchenko
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.
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.
@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.
agreed, much much better to have something in there than nothing!
if you could get a PR in under the wire that would be amazing! :smiley:
Uncertain if I will get to it tonight but will look into it after kids go to bed. :wink:
I added a pull request here. We'll see what they say.
they weren't convinced, it seems
Well, the provided examples where indeed not real-world examples.
Maybe roc-parser would be a good example? It's not "official" and is actually used, not just a toy-project/example
Yeah, roc-pg could be good as well
I wonder what do they mean exactly by real world? Do packages count? Maybe AoC? monkey-roc?
roc-parser, roc-pg, and monkey-roc all seem like good examples! :thumbs_up:
could also do roc-iso8601
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.
Don't sweat it :)
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:
hopefully that can turn into a quick merge and then we'll be in with the next batch!
Our Dict.roc file might be good too
It is a full implementation of something used in production at multiple places.
from the comment it sounds like they're specifically looking for examples outside the official language repos
Makes sense
@Brendan Hansknecht what is the license of Eval.roc? Are you fine with UPL?
Yeah. Go for it
I’ve updated the samples. We'll see if it goes through.
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.
@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:
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
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
Who controls its integration?
I updated the code samples to meet their requirements. Just waiting on them to approve now.
Merged 22 mins ago!:partying_face:
Thanks for the sustained effort @Ryan Bates :heart:
Nice! Looking forward to seeing it live on GitHub.
Me too :)
amazing!!! Thank you so much to everyone who helped get this in! :heart_eyes:
Looks like it is live. :tada:
It is so fun to see Roc in the breakdown of languages in a github repo :star_struck:
It's even using the Roc purple color :)
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
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.
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!
It's such a pleasure to start code snippets with ```roc
:big_smile:
image.png
Last updated: Jul 05 2025 at 12:14 UTC