phoenixframework / vscode-phoenix

Syntax highlighting support for Phoenix templates in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=phoenixframework.phoenix
MIT License
160 stars 10 forks source link

Syntax highlight in sigil_H only works if it ends exactly in """ #7

Open bamorim opened 2 years ago

bamorim commented 2 years ago

imagem imagem

I'm not sure if just adding the case for """) is enough or if we need to be more "elixir-aware".

Other scenarios would be having ~H inside arrays, so we could have """, but then it can also be inside a tuple, which depending on the scenario can be formatted with """, anything here}

I think the main problem is that the elixir formatter changes

foo(
  ~H"""
    <div>something</div>
  """
)

into

foo(~H"""
  <div>something</div>
""")

Which makes so that the "correct format" doesn't highlight properly.

Is there anything I can do to help with that?

bamorim commented 2 years ago

My current workaround is to either change my formatter so rendered_to_string is no-parens or to assign the result to a variable and then call the rendered_to_string afterwards.

Sgoettschkes commented 2 years ago

I'm having the same issue. Seems like the regex at https://github.com/phoenixframework/vscode-phoenix/blob/main/syntaxes/elixir-heex.json#L14 is too strict. I don't have any experience with VScode extension and highlights and am wondering if not matching for the line end would work: "end": "^\\s*(\"\"\")",?