MEGA-ISSUE: Syntax highlighting in `language-ruby`
IMPORTANT: Some issues have already been fixed!
If you’re still on the regular 1.113 release, you might be suffering from a problem that has already been fixed. Many fixes landed on master in #859. You are encouraged to download the latest rolling release — both (a) to see whether what you’re reporting has been fixed, and (b) so that you can enjoy the fixes that have been reported since the 1.113 release.
This will serve as a catch-all issue for any problems you may encounter with syntax highlighting in Ruby files (language-ruby). If you have problems with the new syntax highlighting (or folds, or indents) that are specific to .rb files, keep reading.
Something isn't highlighting correctly!
If you’ve found any highlighting regressions since 1.113:
First, please scroll down and see if someone else has reported the issue. If so, then you need only sit back and wait for a fix — most issues will be fixed in version 1.114!
If not, please comment with
- A small amount of sample code to reproduce the issue
- Screenshots (before and after would be ideal, but just the “after” is OK for obvious things
I want to go back to the old highlighting!
You can easily opt out of the new Tree-sitter highlighting for any language, but first please:
- subscribe to this issue so you'll know when the problem is fixed
- remove the config change when the next release comes out so that you can enjoy the new grammar once again
To revert to the old Tree-sitter grammar for this language only, add the following to your config.cson:
".ruby.source":
core:
useLegacyTreeSitter: true
To revert to the TextMate-style grammar for this language only, add the following to your config.cson:
".ruby.source":
core:
useTreeSitterParsers: false
I hope I've understood it right, that any Ruby highlighting issue should be reported here, as an MEGA-issue's comment.
I've found one, pretty difficult probably: nested heredocs.
Without nesting everything is OK:
With nesting a lot of things break:
But it's still valid Ruby code and executable.
Code example:
# frozen_string_literal: true
some_hosts = ['192.168.1.56', '10.0.3.2']
some_config = <<~CONFIG
#{some_hosts.map do |some_host|
<<~SSH_HOST
---
kind: SSHHost
host: #{some_host}
SSH_HOST
end.join}
CONFIG
def log(data)
puts data
end
log some_config
(even on GitHub it seems broken, lol)
With useLegacyTreeSitter: true it seems different, but still broken:
With useTreeSitterParsers: false it seems almost correct:
Oh, and Pulsar version 1.123.0.
@AlexWayfer yeah, this one isn't handled right by Tree-sitter itself. I'd encourage you to file a bug against tree-sitter-ruby and give that exact code snippet as an example.
EDIT: Lots of similar constructs work — including replacing the inner heredoc with a double-quoted string — so the problem seems to be specific to nested heredocs. In the general case, tree-sitter-ruby seems to allow #{} interpolations within strings within other #{} interpolations within strings.
EDIT 2: There's an existing issue, so perhaps your example could be posted as a comment on that issue.