4 Replies Last post: Dec 30, 2013 4:46 PM by Alexandre I.  
Alexandre I. Newbie 37 posts since
Dec 24, 2013
Currently Being Moderated

Dec 24, 2013 3:00 AM

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 !

Elena Pogorelova Apprentice 1,038 posts since
Oct 5, 2011
Currently Being Moderated
Dec 24, 2013 2:59 PM in response to: Alexandre I.
Re: Custom language in WebStorm : possible ?

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)

Elena Pogorelova Apprentice 1,038 posts since
Oct 5, 2011
Currently Being Moderated
Dec 24, 2013 7:27 PM in response to: Alexandre I.
Re: Custom language in WebStorm : possible ?

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

More Like This

  • Retrieving data ...