Skip to content

feat: add keyword subcategories to Ruby highlights#275

Open
infinityrobot wants to merge 2 commits intozed-extensions:mainfrom
infinityrobot:feat/keyword-subcategories
Open

feat: add keyword subcategories to Ruby highlights#275
infinityrobot wants to merge 2 commits intozed-extensions:mainfrom
infinityrobot:feat/keyword-subcategories

Conversation

@infinityrobot
Copy link

Summary

Splits the monolithic @keyword capture in Ruby's highlights.scm into semantic subcategories, enabling themes to style different keyword types independently.

New captures

Capture Keywords
@keyword.function class, def, module
@keyword.control.conditional if, elsif, else, unless, case, when, then
@keyword.control.repeat while, until, for, do
@keyword.control.return return, next, break, retry, yield
@keyword.exception begin, ensure, rescue (alongside existing raise/fail/catch/throw)
@keyword alias, and, end, in, or (general/structural)

Backward compatibility

Fully backward compatible — themes that only define keyword will continue to work via Zed's fallback resolution (e.g. keyword.control.returnkeyword.controlkeyword).

Precedent

Follows the pattern already established by the SCSS extension, which uses keyword.control.conditional, keyword.control.return, keyword.function, and keyword.repeat.

Motivation

Currently it's impossible to visually distinguish return/yield from def/end or if/unless in Ruby. This is a common theme customisation need — other editors (VS Code, Sublime) support this level of granularity. This change brings Ruby in line with other Zed language extensions that already provide keyword subcategories.

Split the monolithic `@keyword` capture into semantic subcategories,
enabling themes to differentiate between definition, conditional, loop,
flow control, and exception keywords.

New captures:
- `@keyword.function` — class, def, module
- `@keyword.control.conditional` — if, elsif, else, unless, case, when, then
- `@keyword.control.repeat` — while, until, for, do
- `@keyword.control.return` — return, next, break, retry, yield
- `@keyword.exception` — begin, ensure, rescue (+ existing raise/fail/catch/throw)
- `@keyword` — alias, and, end, in, or (general/structural)

This is fully backward compatible — themes that only define `keyword`
will continue to work via Zed's fallback resolution (e.g.
`keyword.control.return` → `keyword.control` → `keyword`).

Follows the precedent set by the SCSS extension which already uses
`keyword.control.conditional`, `keyword.control.return`,
`keyword.function`, and `keyword.repeat`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cla-bot
Copy link

cla-bot bot commented Mar 25, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @infinityrobot on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@infinityrobot
Copy link
Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed label Mar 25, 2026
@cla-bot
Copy link

cla-bot bot commented Mar 25, 2026

The cla-bot has been summoned, and re-checked this pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant