Skip to content

feat: Add Ruby syntax highlight support#849

Open
toshimaru wants to merge 3 commits intomicrosoft:mainfrom
toshimaru:ruby-syntax-highlight
Open

feat: Add Ruby syntax highlight support#849
toshimaru wants to merge 3 commits intomicrosoft:mainfrom
toshimaru:ruby-syntax-highlight

Conversation

@toshimaru
Copy link
Copy Markdown

@toshimaru toshimaru commented May 4, 2026

Adds an LSH definition for Ruby and a matching highlighting-test fixture.

Registered for *.rb, *.rake, *.ru, Gemfile, and Rakefile. The definition covers:

  • Comments — line (#…) and block (=begin / =end)
  • Strings — single-quoted, double-quoted, and backtick command strings, with \. escapes
  • Numeric literals — decimal, hex (0x…), binary (0b…), octal (0o…), floats and exponents, with _ separators and r / i rational/imaginary suffixes
  • Keywords — control flow (if, case, while, rescue, …) and other (class, module, def, self, super, …)
  • Constants — true, false, nil, and capitalized identifiers
  • Variables and symbols — @ivar, @@cvar, $gvar, :symbol
  • Method definitions and call sites — including ! / ? / = suffixes

assets/highlighting-tests/ruby.rb exercises each category for visual verification.

Screenshot CleanShot 2026-05-05 at 00 12 20@2x

@toshimaru toshimaru marked this pull request as ready for review May 4, 2026 07:49
Copilot AI review requested due to automatic review settings May 4, 2026 07:49
@toshimaru
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class Ruby support to the LSH syntax-highlighting system by introducing a Ruby lexer definition and a corresponding highlighting fixture for visual verification.

Changes:

  • Added a new Ruby .lsh definition with file associations for common Ruby filenames and extensions.
  • Implemented highlighting rules for Ruby comments, strings, numbers, keywords, constants, variables/symbols, and method defs/calls.
  • Added assets/highlighting-tests/ruby.rb to exercise the new token categories.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/lsh/definitions/ruby.lsh New Ruby highlighting definition and file associations.
assets/highlighting-tests/ruby.rb New Ruby fixture file to manually/visually validate highlighting behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/lsh/definitions/ruby.lsh Outdated
Comment thread crates/lsh/definitions/ruby.lsh Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/lsh/definitions/ruby.lsh Outdated
Comment thread assets/highlighting-tests/ruby.rb Outdated
toshimaru added 2 commits May 4, 2026 22:38
- Fix Ruby keyword and variable highlighting
- use `keyword.control` for `end`
@toshimaru toshimaru force-pushed the ruby-syntax-highlight branch from 0a5f32e to 07cbc0d Compare May 4, 2026 15:08
lczyk added a commit to lczyk/edit-lczyk-remix that referenced this pull request May 5, 2026
ports microsoft#849 by toshimaru. adds an lsh definition for
ruby and a kitchen-sink fixture covering comments, strings, numerics,
keywords, constants, variables, symbols, and method defs.

registered for *.rb, *.rake, *.ru, Gemfile, Rakefile.

local additions on top of the upstream PR:
- #[line_comment = "#"] attr to match this fork's other defs
- fixture lives under crates/lsh/tests/fixtures/ruby/ w/ a .jsonl
  golden snapshot, per the local golden-test layout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants