Adding Heredoc syntax Highlighting in VSCode

255 Views Asked by At

I have a Rails project in which I'm using View Components. Inside most components, I have a erb_template HEREDOC which defines the components markup using ERB templated HTML.

When I set the HEREDOC opening tag to HTML (uppercase only), I get html syntax highlighting. Likewise, if I set it to RUBY, I get ruby syntax highlighting and so on.

I'm struggling to find where I can configure this kind of embedded syntax highlighting and add ERB support. Has anyone done this successfully?

Example of component

1

There are 1 best solutions below

0
Joe Van Dyk On

See this github issue which discusses adding more languages to the heredoc: https://github.com/Shopify/vscode-ruby-lsp/issues/820

I believe you can change grammars/ruby.cson.json and submit a PR to vscode-ruby-lsp. The file used to be at https://github.com/atom/language-ruby/ but I believe that repo looks locked/archived.