Stream: bugs

Topic: Zed plugin incorrectly highlights "to" inside identifiers


view this post on Zulip Ruby (Aug 11 2025 at 17:41):

I've noticed that the Zed extension for Roc incorrectly highlights "to" as a keyword even when it's part of a variable name. For example, if I have a variable called todos, the "to" part gets highlighted as a keyword.

This doesn't happen in nvim with the same tree-sitter-roc grammar, so it seems to be specific to how the Zed extension is configured.

Looking at the extension's highlights.scm, I found this:

[
(implements)
(when)
(is)
"as"
(to)
] @keyword.control.roc

My questions:

  1. Is "to" actually a keyword in Roc? I only see it used in module headers like:
    roc app "test" provides [main] to "./platform"

  2. Should "to" be highlighted at all? I notice nvim doesn't highlight it.

  3. Is this (to) node type necessary, or is it a bug in the Zed extension configuration?

My fix: I removed the (to) line from the highlights.scm and now variables like todos display correctly. But I'm not sure if this breaks highlighting for legitimate uses of "to".

Would love to know if I'm understanding this correctly and whether "to" should be treated as a keyword in Roc.

view this post on Zulip Anton (Aug 11 2025 at 17:46):

Hi @Ruby,
This header style is no longer used:

app "test" provides [main] to "./platform"

I did some checking and to is no longer a keyword and does not need to be highlighted anymore, so I think your fix is correct.

view this post on Zulip Ruby (Aug 11 2025 at 17:47):

Yes, I found that example somewhere deep in the roc codebase and wasn't completely sure about it.

Thanks :pray:

view this post on Zulip Anton (Aug 11 2025 at 18:05):

I did some extra digging, to still is a header keyword, so not considered a full keyword (past the header) and this old header style does still work with the old (rust) compiler. to has been completely removed from the new (zig) compiler as far as I could tell. You could say it's been informally deprecated :p Preventing to from being highlighted everywhere in the code is still a good fix, because it was never a full keyword to begin with.

view this post on Zulip Ruby (Aug 12 2025 at 14:03):

Thanks!


Last updated: Aug 17 2025 at 12:14 UTC