From 9b41fe6c397c19a2ae5b5dfb5d7af476bc4964ab Mon Sep 17 00:00:00 2001 From: Marco Roth Date: Sat, 8 Nov 2025 21:01:13 +0100 Subject: [PATCH 1/2] feat: Add RBS Inline syntax highlighting support --- extension.toml | 4 ++-- languages/rbs/highlights.scm | 3 +++ languages/ruby/highlights.scm | 5 ++++- languages/ruby/injections.scm | 17 +++++++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/extension.toml b/extension.toml index eca5d00..9400e49 100644 --- a/extension.toml +++ b/extension.toml @@ -47,8 +47,8 @@ repository = "https://github.com/tree-sitter/tree-sitter-embedded-template" commit = "c70c1de07dedd532089c0c90835c8ed9fa694f5c" [grammars.rbs] -repository = "https://github.com/joker1007/tree-sitter-rbs" -commit = "de893b166476205b09e79cd3689f95831269579a" +repository = "https://github.com/marcoroth/tree-sitter-rbs" +commit = "4924a673da166d4461492dbdebd8bb37095ddcc0" [[capabilities]] kind = "process:exec" diff --git a/languages/rbs/highlights.scm b/languages/rbs/highlights.scm index 4ab0b1a..3b25478 100644 --- a/languages/rbs/highlights.scm +++ b/languages/rbs/highlights.scm @@ -161,3 +161,6 @@ "," "." ] @punctuation.delimiter + +; RBS Inline prefix (keep comment color) +(inline_prefix) @comment diff --git a/languages/ruby/highlights.scm b/languages/ruby/highlights.scm index 2ee9103..0b81895 100644 --- a/languages/ruby/highlights.scm +++ b/languages/ruby/highlights.scm @@ -143,7 +143,10 @@ (nil) ] @constant.builtin -(comment) @comment +; Regular comments (exclude RBS inline comments) +((comment) @comment + (#not-match? @comment "^\\s*#[:|]") + (#not-match? @comment "^\\s*#\\s*(@rbs|\\|)")) ; Operators diff --git a/languages/ruby/injections.scm b/languages/ruby/injections.scm index b7f5d4c..f91d93c 100644 --- a/languages/ruby/injections.scm +++ b/languages/ruby/injections.scm @@ -7,5 +7,22 @@ (string_content) @content) (#set! "language" "regex")) +; RBS Inline: #: syntax +((comment) @content + (#match? @content "^\\s*#:") + (#set! injection.language "rbs")) + +; RBS Inline: # @rbs syntax +((comment) @content + (#match? @content "^\\s*#\\s*@rbs") + (#set! injection.language "rbs")) + +; RBS Inline: continuation lines (e.g., "#| param: Type" or "# | (?Regexp?) -> void") +; Note: These will parse with errors since they're not complete RBS on their own, +; but types within them will still get highlighted +((comment) @content + (#match? @content "^\\s*#\\s*\\|") + (#set! injection.language "rbs")) + ((comment) @content (#set! injection.language "comment")) From 47d0784935431588ff837dd95a3e59251d617a01 Mon Sep 17 00:00:00 2001 From: Marco Roth Date: Sun, 9 Nov 2025 16:56:37 +0100 Subject: [PATCH 2/2] chore: update `tree-sitter-rbs` to `v0.2.0` https://github.com/joker1007/tree-sitter-rbs/releases/tag/v0.2.0 --- extension.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extension.toml b/extension.toml index 9400e49..953aa07 100644 --- a/extension.toml +++ b/extension.toml @@ -47,8 +47,8 @@ repository = "https://github.com/tree-sitter/tree-sitter-embedded-template" commit = "c70c1de07dedd532089c0c90835c8ed9fa694f5c" [grammars.rbs] -repository = "https://github.com/marcoroth/tree-sitter-rbs" -commit = "4924a673da166d4461492dbdebd8bb37095ddcc0" +repository = "https://github.com/joker1007/tree-sitter-rbs" +commit = "6bcfa169021a9cc40fb47cd75ef4b4d3767d6ab5" [[capabilities]] kind = "process:exec"