Reputation: 467
I have been able to add syntax highlighting to my .liquid
files by following the instructions here: Enabling Liquid templating syntax highlight in webStorm/phpStorm
It worked fine for my HTML and liquid syntax highlighting as it's so similar to Twig.
But my issue is I also have my schema
included in each of my .liquid
templates. The schema is JSON but there's not syntax highlighting on it at all.
Is there a way to add a custom syntax highlighting for a file type if it's wrapped in some sort of delimiter?
My schema is wrapped like so:
{% schema %}
JSON object with my settings/configuration
{% endschema %}
Upvotes: 4
Views: 2395
Reputation: 1708
Jetbrains added support for permanent language references using annotations. Here is sample from PhpStorm for PHP (pretty sure, that something similar you should have for your language as well)
After that string will be nicely formatted
Upvotes: 0
Reputation: 11607
.amg
filetype for an internal framework that is essentially just a JSONIntelliJ
treat those as JSONs by adding *.amg
pattern under Recognized File Types
> JSON
reference: JetBrains / File type associations
Upvotes: 0
Reputation: 165088
As @yole have said: you cannot do that. Well... permanently.
You can always inject JSON there manually .. and it will last for a while (a session for sure).
Just place caret just after {% schema %}
and hit Alt + Enter.
Choose Inject language or reference
and locate JSON
in the list (speed search works there as well, so just start typing).
Result is obvious:
You are using Twig plugin for .liquid
files (native support for them (RUBY-7210) does not seem to be on JetBrains short list right now).
It's now possible to have permanent Language Injection in custom Twig tag (using Twig plugin). See the screenshot below for custom injection rule that you can create yourself:
Upvotes: 7
Reputation: 93728
You can inject JSON in your {% schema %}
block manually via Alt+Enter
, Inject language or reference > JSON:
See also https://blog.jetbrains.com/phpstorm/2017/12/twig-handling-improvements/
Upvotes: 1