webstormvelocityjetbrains-idetextmatebundles

Syntax highlighting of unsupported language in WebStorm with TextMate bundle


The usual answer to this question is, "download and add a suitable TextMate bundle." I have done that.

I'm working in WebStorm on a React project using GraphQL. It has a lot of .vtl (Velocity Template Language) files that do not have syntax highlighting. I found out that I can add a TextMate bundle for VTL in order to get highlighting. I got this bundle from https://github.com/textmate/java-velocity.tmbundle. After adding it to WebStorm, there still isn't an appropriate file type, and .vtl files still don't have syntax highlighting.

So, I tried to create a new custom file type, manually supplying lists of keywords to highlight, which make the code slightly more readable. However, every .vtl file is now entirely marked with squiggly red, saying, "Unexpected tokens." I just wanted keyword highlighting, not incorrect assumptions about grammar.

Is this a problem with WebStorm, the bundle, or me? How can I get some basic syntax highlighting specifically for .vtl files?

Note that the TextMate plugin is installed.


Solution

  • The bundle only provides highlighting for *.vm files. Please check if the issue persists if you open java-velocity.tmbundle\Syntaxes\Velocity.tmLanguage file in some text editor and add vtl to the list of supported extensions:

    <key>fileTypes</key>
        <array>
            <string>vm</string>
            <string>vtl</string>
        </array>
    

    and re-start the IDE? Note that you need to remove your custom file type to get the extension recognized