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

cannot inject a language into an elixir string #695

Open
nhooyr opened this issue May 7, 2017 · 9 comments
Open

cannot inject a language into an elixir string #695

nhooyr opened this issue May 7, 2017 · 9 comments

Comments

@nhooyr
Copy link

nhooyr commented May 7, 2017

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
Copy link
Owner

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
Copy link
Author

nhooyr commented May 7, 2017

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
Copy link
Author

nhooyr commented Nov 22, 2019

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

@nhooyr nhooyr closed this as completed Nov 22, 2019
@niknetniko
Copy link
Contributor

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.

@KronicDeth KronicDeth reopened this May 16, 2020
@abcd-ca
Copy link

abcd-ca commented Nov 27, 2020

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
Copy link

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
Copy link

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

@codylandry
Copy link

+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
Copy link
Owner

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

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

No branches or pull requests

7 participants