Skip to content

Commit 303d43d

Browse files
feat: add keyword subcategories to Ruby highlights (#275)
## 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.return` → `keyword.control` → `keyword`). ### 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. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0b2935f commit 303d43d

1 file changed

Lines changed: 38 additions & 18 deletions

File tree

languages/ruby/highlights.scm

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,55 @@
44
(global_variable)
55
] @variable
66

7-
; Keywords
7+
; Keywords — definition
88
[
9-
"alias"
10-
"and"
11-
"begin"
12-
"break"
13-
"case"
149
"class"
1510
"def"
16-
"do"
11+
"module"
12+
] @keyword.function
13+
14+
; Keywords — conditional
15+
[
16+
"case"
1717
"else"
1818
"elsif"
19-
"end"
20-
"ensure"
21-
"for"
2219
"if"
23-
"in"
24-
"module"
25-
"next"
26-
"or"
27-
"rescue"
28-
"retry"
29-
"return"
3020
"then"
3121
"unless"
32-
"until"
3322
"when"
23+
] @keyword.control.conditional
24+
25+
; Keywords — loop
26+
[
27+
"do"
28+
"for"
29+
"until"
3430
"while"
31+
] @keyword.control.repeat
32+
33+
; Keywords — flow return/jump
34+
[
35+
"break"
36+
"next"
37+
"retry"
38+
"return"
3539
"yield"
40+
] @keyword.control.return
41+
42+
; Keywords — exception handling
43+
[
44+
"begin"
45+
"ensure"
46+
"rescue"
47+
] @keyword.exception
48+
49+
; Keywords — general
50+
[
51+
"alias"
52+
"and"
53+
"end"
54+
"in"
55+
"or"
3656
] @keyword
3757

3858
((identifier) @keyword

0 commit comments

Comments
 (0)