Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MEGA-ISSUE: Syntax highlighting in language-ruby #881

Open
savetheclocktower opened this issue Jan 19, 2024 · 2 comments
Open

MEGA-ISSUE: Syntax highlighting in language-ruby #881

savetheclocktower opened this issue Jan 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@savetheclocktower
Copy link
Contributor

savetheclocktower commented Jan 19, 2024

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
@savetheclocktower savetheclocktower added the bug Something isn't working label Jan 19, 2024
@AlexWayfer
Copy link

AlexWayfer commented Nov 28, 2024

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:

image

With nesting a lot of things break:

image

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:

2024-11-28_14-47

With useTreeSitterParsers: false it seems almost correct:

image

Oh, and Pulsar version 1.123.0.

@savetheclocktower
Copy link
Contributor Author

savetheclocktower commented Nov 28, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants