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
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 :
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
var test = "foo<%MyFunc(arg=|value|)%>bar";
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 !
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)
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 ?
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
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..