title: IntelliJ: custom language: combine fragments in other languages
body: <p>I am creating a custom language plugin for IntelliJ.</p>
  
  <p>I would like it to be possible for a file in the new language to contain fragments of text in other languages.</p>
  
  <p>The specific languages I would like to support are HTML, JS, CSS, and SQL.</p>
  
  <p>I would also like to support other custom languages (i.e. languages I would define the syntax for).</p>
  
  <p>The main feature I want is syntax coloring, but if I can get stuff like "go to declaration" and refactoring out of the box then all the better.</p>
  
  <p>My last requirement is that it would be possible to use my own code to tell IntelliJ which language a fragment contains; fragments containing different languages will not be distinguishable at the lexer / parser level.</p>
  
  <p>In short, I would like to implement something similar to what PhpStorm does when it detects, say, SQL inside a string:</p>
  
  <p><a href="https://i.stack.imgur.com/flhkh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/flhkh.png" alt="enter image description here"></a></p>
  
  <p>I looked at IntelliJ's source code and found the ILazyParseableElementType interface which seemed relevant, but I'm not sure if this is the way to go (and if so - how to use it in my code exactly...)</p>
  
  <p>Any pointers would be highly appreciated...</p>