Custom language in WebStorm : possible ?

Hi all,

our company is currently evaluating the migration to WebStorm as our main development IDE and I would like to ask the following question :

We use a custom kind of "language" in our files which is actually very close to ASP.

Our files are html files or macro files.

Macro files contain lists of chunks of html like

MyMacro1 [
<div>Some html</div>
]

MyMacro2 ...

Each html file or a chunk inside a macro file can contain calls to our custom functions like <%MyFunc()%>, we have our own list of such functions that we would like to be highlighted / autocompleted if possible.

Our functions accept arguments, with the following three argument quote possibilities :

<%MyFunc(arg="value")%> or <%MyFunc(arg='value')%> or <%MyFunc(arg=|value|)%>

They can also be nested :

<%MyFunc(arg="<%MyFunc2(arg2='value2')%>")%>

Both these constructs can be inserted in the main files (html or macros) anywhere, in the HTML part, but also inside any script that is present inside a regular <script> tag such as

     <script>
          var test = "foo<%MyFunc(arg=|value|)%>bar";
     </script>

Is it possible to make WebStorm recognize this kind of syntax and how please ?

We could pretend it is ASP and place our file extension in the ASP file type, but it doesn't seem to give the desired result, because then the HTML is not properly highlighted... If I define our type as HTML, then our tags do not get properly handled when presend inside scripts and so on...

Thanks in advance for your help !

4 comments

Hello!

you can try associating your files with EJS file type (Settings/File Types, 'EJS combines data and a template to produce HTML')
But, I fear, it won't work any better than .asp association

So the solution is common for all custom language - develop your own plugin (http://confluence.jetbrains.com/display/IDEADEV/Developing+Custom+Language+Plugins+for+IntelliJ+IDEA)

0

Thanks Elena.

Acutally it's not even a proper language per se, just a set of additional tags to HTML, kind of.

Is there an open source example of a language plugin somewhere please ?

Also, how come some of the language plugins in the plugin repository do work in Webstorm, and some don't ? How to make ours work in Webstorm specifically ?

Thanks

0

Please check this tutorial:http://confluence.jetbrains.com/display/IntelliJIDEA/Custom+Language+Support
Code is available on GitHub: https://github.com/cheptsov/SimplePlugin

>Also, how come some of the language plugins in the plugin repository do work in Webstorm, and some don't ?

Plugin compatibility with different products is detected based on plugin dependencies -  the plugin is loaded if the product contains all of the modules on which the plugin depends. See http://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
So, if your plugin doesn't depend on the modules missing in WebStorm, it will be available there


Note that we have a special forum for questions regarding plugins development - http://devnet.jetbrains.com/community/idea/open_api_and_plugin_development

0

Thanks for the reply. Now imagine we have developed the plugin for the custom language.

How to define that in HTML files, everytime a <% is encountered it should trigger a language injection of our language, util the closing %> ?

I only see XML tag or attribute injection types in the settings.

or should our language be defined as host language and HTML as its template language ?

If so, do we still need language injections ?

And last but not least... The example language is a very simple language which is good for a tutorial, but it seems to be a standalone kind of language. Would there be somewhere some example source code for a host language like ASP or PHP and so on ?

It is clearly a bit of a difficulty and kind of a show stopped for now, because Webstorm highlights a lot of warnings and errors everywhere in our HTML, so it's quite hard to evaluate and work with it as it is..

Thanks !

0

Please sign in to leave a comment.