Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

(feature request) Heredoc Slim support (or a way to add custom heredoc syntaxes) #274

Closed
rafasoares opened this issue Feb 22, 2018 · 5 comments
Assignees

Comments

@rafasoares
Copy link

Environment

  • vscode-ruby version: 0.16.0
  • Ruby version: 2.5.0
  • VS Code version: 1.20.1
  • Operating System: macOS High Sierra 10.13.3

Expected behavior

Color Slim heredocs syntax the same way it works with HTML

Actual behavior

Slim heredocs are colored as strings

Steps to reproduce the problem

screen shot 2018-02-22 at 9 51 52 am

Additional Notes

Perhaps the best approach would be to allow a setting for custom heredoc matching. Something like:

"ruby.heredoc.customSyntaxes": {
  "SLIM": "slim",
  "MATCHER": "vscode-syntax-key"
}
@wingrunr21
Copy link
Collaborator

Hmm, I will look into this.

This also raises a larger question as to whether we should be directly supporting HAML or Slim or leaving that to other extensions.

@wingrunr21 wingrunr21 self-assigned this Apr 4, 2018
@rafasoares
Copy link
Author

That's why I suggested the customization options. Simply set a matcher and the syntax key. The highlighting itself would be handled by VS Code or the appropriate extension.

I'm pretty sure this is how it works already (looking at

"comment": "Heredoc with embedded html",
), but with a fixed list of syntaxes, thus adding another one for Slim would be a lot easier. Unless I missed something and you include syntax rules for things like SQL, GraphQL, CSS and XML in the vscode-ruby extension, of course.

@wingrunr21
Copy link
Collaborator

Except the syntax is loaded at extension load time and I've not yet found a way to modify the syntax via runtime configuration options

@rafasoares
Copy link
Author

rafasoares commented Apr 4, 2018

I see. Is there no way to reload the extension upon changes in ruby.* settings?

PS: This is why I thought just adding a "Heredoc with embedded Slim" syntax would be easier.

@wingrunr21
Copy link
Collaborator

wingrunr21 commented Apr 4, 2018

Reloading the extension wouldn't do anything. VSCode loads the grammar based on the stuff in package.json and uses that for syntax highlighting.

I also don't want to be doing one-off edits to the grammar just to support specific uses cases. For instance, there's nothing that requires you to use <<-SLIM as the heredoc delimiter. How would we support slim detection via <<-TEMPLATE? Allowing VSCode to properly detect embedded languages and apply the appropriate syntax is a better option here (similar to what we do with ERB here). The problem with this approach is that it's basically going to require an entry for every language you can embed in a Heredoc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants