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

Turn on semantic highlighting for ERB #2542

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

vinistock
Copy link
Member

Motivation

I noticed semantic highlighting was turned off for ERB files. We should turn it on to get proper highlighting, especially in blocks with arguments.

For example, the user usage below was not properly highlighted, but after this change it is.

<% @users.each do |user| %>
  <%= user.name %>
<% end %>

@vinistock vinistock added enhancement New feature or request server This pull request should be included in the server gem's release notes labels Sep 11, 2024
@vinistock vinistock self-assigned this Sep 11, 2024
@vinistock vinistock requested a review from a team as a code owner September 11, 2024 20:52
Copy link
Contributor

@andyw8 andyw8 left a comment

Choose a reason for hiding this comment

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

Could there be any issues with this when the file is ERB but with another language, e.g. YAML?

@vinistock
Copy link
Member Author

There shouldn't be. Our ERB scanner separates the embedded Ruby from the host language, regardless of what the host language is.

@vinistock vinistock merged commit f329dc0 into main Sep 12, 2024
35 checks passed
@vinistock vinistock deleted the vs-turn-on-semantic-highlighting-for-erb branch September 12, 2024 14:09
@@ -39,7 +39,7 @@ class << self
sig { returns(Interface::SemanticTokensRegistrationOptions) }
def provider
Interface::SemanticTokensRegistrationOptions.new(
document_selector: [{ language: "ruby" }],
document_selector: [{ language: "ruby" }, { language: "erb" }],
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this also have , { language: "eruby" } for the (Neo)vim crowd?

Copy link
Member Author

Choose a reason for hiding this comment

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

The last time we tried turning ERB on for NeoVim, some limitations were identified #2432 (comment).

Someone would need to confirm if NeoVim is properly respecting the server's returned document selector and then we can make the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants