KronicDeth / intellij-elixir

Elixir plugin for JetBrain's IntelliJ Platform (including Rubymine)
Other
1.84k stars 153 forks source link

cannot inject a language into an elixir string #695

Open nhooyr opened 7 years ago

nhooyr commented 7 years ago

Oddly enough, I can inject a language into an elixir comment, but not a string. It works fine for other languages, so I think it is something wrong with this plugin.

KronicDeth commented 7 years ago

There's probably some interface I need to implement or method I need to override that disallows injection in the default implementation. Probably something that keeps track of what counts as a "String" in the language and should allow injection. The comments are already marked as comments for the grammar definition, which is why that probably works.

Can you give me specific steps for what you're trying to do, so I can replicate?

nhooyr commented 7 years ago

I created an elixir project, created an elixir file and entered in two double quotes. I put my cursor within those quotes, pressed ALT+ENTER and IntelliJ did not offer me the language injection popup. I did the same after entering a comment, putting my cursor somewhere in the comment, pressing ALT+ENTER and it showed me the language injection popup.

This isn't too important considering I'm gonna use ecto anyway, but something that should work.

nhooyr commented 4 years ago

Going to close as it has been a long time and I'm not sure if this is relevant anymore.

niknetniko commented 4 years ago

I would like this to be re-opened, since it is still relevant. I still can't inject another language into an Elixir string (for example SQL in a migration in execute("SELECT * FROM ...")).

I think PsiLanguageInjectionHost needs to be implemented for Elixir strings.

abcd-ca commented 3 years ago

I'm missing this feature too. Here's my example from an .ex file. I can't get language injection to work for the html in my multiline string:

  defp generate_body_html() do
    ~e"""
    <html>
    <head>
          <link rel="preconnect" href="https://fonts.gstatic.com">
          <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
    </head>

    <body>Hello World</body>
    </html>
    """
    |> Phoenix.HTML.safe_to_string()
  end
JohannesSoots commented 3 years ago

Would also love to get this working with the Surface ~H sigil.

    def render(assigns) do
      ~H"""
      <div class={{ "modal", "is-active": @show }}>
        <div class="modal-background"></div>
        <div class="modal-card">
          <header class="modal-card-head">
            <p class="modal-card-title">{{ @title }}</p>
          </header>
          <section class="modal-card-body">
            <slot/>
          </section>
          <footer class="modal-card-foot" style="justify-content: flex-end">
            <Button click={{ @hideEvent }}>Ok</Button>
          </footer>
        </div>
      </div>
      """
    end
edgarmiadzieles commented 3 years ago

I see this still as relevant as this would improve the experience by quite a lot. +1 on the Surface sigil aswell.

codylandry commented 2 years ago

+1 on this as well! I'm not familiar with java/kotlin or parsers for that matter, but this page seems related:

https://plugins.jetbrains.com/docs/intellij/language-injection.html#implementation

KronicDeth commented 2 years ago

Each sigil is going to be a separate issue. Please stop piling every feature together.