From a8ce0527ad9c8d9c764eed0b6c72f03d61bcf7da Mon Sep 17 00:00:00 2001 From: Ritchie Cotton <243725+infinityrobot@users.noreply.github.com> Date: Wed, 25 Mar 2026 11:36:05 +1100 Subject: [PATCH] feat: add keyword subcategories to Ruby highlights MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- languages/ruby/highlights.scm | 56 ++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/languages/ruby/highlights.scm b/languages/ruby/highlights.scm index 708ea2e..2f97044 100644 --- a/languages/ruby/highlights.scm +++ b/languages/ruby/highlights.scm @@ -4,35 +4,55 @@ (global_variable) ] @variable -; Keywords +; Keywords — definition [ - "alias" - "and" - "begin" - "break" - "case" "class" "def" - "do" + "module" +] @keyword.function + +; Keywords — conditional +[ + "case" "else" "elsif" - "end" - "ensure" - "for" "if" - "in" - "module" - "next" - "or" - "rescue" - "retry" - "return" "then" "unless" - "until" "when" +] @keyword.control.conditional + +; Keywords — loop +[ + "do" + "for" + "until" "while" +] @keyword.control.repeat + +; Keywords — flow return/jump +[ + "break" + "next" + "retry" + "return" "yield" +] @keyword.control.return + +; Keywords — exception handling +[ + "begin" + "ensure" + "rescue" +] @keyword.exception + +; Keywords — general +[ + "alias" + "and" + "end" + "in" + "or" ] @keyword ((identifier) @keyword