Is there a way to use multiple languages in a single PhpStorm file?
I am having trouble getting a single file to do proper highlighting/hinting/linting for all these languages at once: PHP, XHTML, Twig, SCSS, JavaScript.
I put up a detailed on StackOverflow that might make things clear: https://stackoverflow.com/questions/62502184/is-there-a-way-to-use-multiple-languages-in-a-single-phpstorm-file
I have a custom file extension, .sfc, that I have associated with PHP. PHP code is correctly recognized, as is XHTML, CSS, and JavaScript. The problem happens when I try to introduce Twig and SCSS. The Twig code is still treated as XHTML and the SCSS code is treated as CSS.
I have tried to figure out language injection comments, but I either don't understand them, or the built-in configurations don't handle Twig and SCSS inside of a PHP file.
Any suggestions on how I can trigger proper recognition fo all 5 languages in one file?
Please sign in to leave a comment.
As I can see there's already a valid reply: https://stackoverflow.com/a/62503254/8020009
There are currently no other options to achieve that
Hi Dmitry,
Thank you for reply. Since I posted the question, I learned a few more things.
It does appear that SCSS can be injected properly using <style type="text/scss"> instead of just <style> (which assumes CSS). JavaScript is of course already supported as <script>. So Twig is the only language missing from the mix.
I put in a feature request to make Twig an injectable language: https://youtrack.jetbrains.com/issue/WI-53909