Can I edit velocity templates in IDEA with syntax highlighting/etc.?

I have just started play around with velocity templates and after watching someone edit it in Eclipse with their velocity plugin with full syntax coloring and code completion, I went looking for a velocity plugin for IDEA.

After searching through the IDEA forums for a while, it looks like a lot of the underlying config files in IDEA are using velocity templates (File Templates appears to be using velocity templates with syntax highlighting and everything). Unforunately I haven't been able to find something talking about how I can get this same kind of support while editing velocity templates myself.

I've found references to IntelliJ-Live-Template.xml that includes a bunch of templates that expand velocity commands to their full structure (adds #ends for instance) but that doesn't seem to be what I need for actually having knowledge of velocity syntax for IDEA. Idea has to be able to do it, as it uses it itself in its configs, so I can't imagine I can't enable that support for my own velocity template editing.

Did I just map .vm files to the wrong handler? I tried text initially, but of course had no editing. When I downloaded and installed the live template file for velocity structures I noticed that they were all set to be applied to HTML files, so I figured maybe IDEA wouldn't handle velocity templates as HTML...changed file type for .vm's from text to HTML and that didn't help. I have no syntax highlighting and still can't get the live templates to work.

Help! I'm sure the support is there and I'm probably just doing something wrong...

15 comments
Comment actions Permalink

I'd love to read an answer about this thread, I'm facing exactly the same problem.
Actually, I'd just be happy if IDEA could cope with velocity type tags (#something) without reporting errors... That would allow me to reformat HTML code...

0
Comment actions Permalink

Yup. I honestly can't believe that there isn't a way to do it, given that Idea uses them for some of its own configs.

No one out there knows the answer here?

0
Comment actions Permalink

Hello Kenny,

KC> Yup. I honestly can't believe that there isn't a way to do it,
KC> given that Idea uses them for some of its own configs.
KC>
KC> No one out there knows the answer here?

The answer is no. There is some rather primitive syntax highlighting enabled
in our file/live template configuration, and that's it.

--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

D'oh!

Well thanks for the answer (even though I was hoping for a different one).

0
Comment actions Permalink

Sounds like a good idea (no pun intended) for a plugin. Do the JetbBrainers
have any plans of adding this (as a plugin or otherwise) in the near future?
If not, I'd be willing to give it a go.

"Kenny Coleman" <no_mail@jetbrains.com> wrote in message
news:9614376.1156840915931.JavaMail.itn@is.intellij.net...

D'oh!

>

Well thanks for the answer (even though I was hoping for a different one).



0
Comment actions Permalink

Hello Brad,

Not in the near future. If you need some advice when writing a plugin, we'll
be happy to help.

BL> Sounds like a good idea (no pun intended) for a plugin. Do the
BL> JetbBrainers have any plans of adding this (as a plugin or
BL> otherwise) in the near future? If not, I'd be willing to give it a
BL> go.

--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

If you need some advice when writing a plugin,
we'll be happy to help.

But you said a while ago that the IntelliJ OpenAPI doesn't have support
(yet) for Template Languages, and it is not possible without "internals" .
This since template languages need to be mixed with other languages - e.g.
like JSP or HTML but not quite like Javascript does (since javascript is embedded and does not
embed like template languages).

Has this changed? If yes, what is the new API ? Is there at least an example how to do it?
(since you mention that not a single new document will be made for 6.0 regarding plug-in development).

Thanks in advance,

Ahmed.

0
Comment actions Permalink

Hello Ahmed,

>> If you need some advice when writing a plugin, we'll be happy to
>> help.
>>
AM> But you said a while ago that the IntelliJ OpenAPI doesn't have support
AM> (yet) for Template Languages, and it is not possible without "internals"
.
AM> This since template languages need to be mixed with other languages -
e.g.
AM> like JSP or HTML but not quite like Javascript does (since
AM> javascript is embedded and does not
AM> embed like template languages).
AM> Has this changed? If yes, what is the new API ? Is there at least an
AM> example how to do it?

The big news in Demetra for this is the language injection API (PsiLanguageInjectionHost
and related classes). GWT Studio plugin uses this API - its source is not
distributed in current builds, but I'll find out whether we plan to distribute
its source in the final release. Also, Sascha Weinreuter is developing a
plugin which uses the API, although as far as I know it hasn't yet been released.

AM> (since you mention that not a single new document will be made for
AM> 6.0 regarding plug-in development).

Sorry, but that's not what I actually said.

--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"




0
Comment actions Permalink

>>> If you need some advice when writing a plugin, we'll be happy to
>>> help.
>>>

AM> But you said a while ago that the IntelliJ OpenAPI doesn't have support
AM> (yet) for Template Languages, and it is not possible without
"internals" .
AM> This since template languages need to be mixed with other languages
- e.g.
AM> like JSP or HTML but not quite like Javascript does (since
AM> javascript is embedded and does not
AM> embed like template languages).
AM> Has this changed? If yes, what is the new API ? Is there at least an
AM> example how to do it?

The big news in Demetra for this is the language injection API
(PsiLanguageInjectionHost and related classes).

GWT Studio plugin uses
this API - its source is not distributed in current builds, but I'll
find out whether we plan to distribute its source in the final release.

Well, why not put it here:
http://svn.jetbrains.org/idea/Trunk/
like all the other plug-ins. Or at least publish that part(or another example) that
is using that API (but something that works).

IMHO it would be a good idea to migrate other
plug-ins from dev.java.net, sourceforge, to jetbrains.org etc. to have everything in one place.

AM> (since you mention that not a single new document will be made for
AM> 6.0 regarding plug-in development).
Sorry, but that's not what I actually said.

No, but the end result is the same :(.

Ahmed.

0
Comment actions Permalink

Hello Ahmed,

>> AM> (since you mention that not a single new document will be made for
>> AM> 6.0 regarding plug-in development).
>> Sorry, but that's not what I actually said.
AM> No, but the end result is the same :(.

That's not true either.
http://www.jetbrains.com/idea/documentation/dom-rp.html

--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

>>> AM> (since you mention that not a single new document will be made for
>>> AM> 6.0 regarding plug-in development).
>>> Sorry, but that's not what I actually said.

AM> No, but the end result is the same :(.

That's not true either.
http://www.jetbrains.com/idea/documentation/dom-rp.html

That document was published on the idea blog a while ago - nothing new there.
I asked you that question almost a month after that document was published :(.

Ahmed.

0
Comment actions Permalink

Dmitry Jemerov wrote:

The big news in Demetra for this is the language injection API
(PsiLanguageInjectionHost and related classes).


The not-so-good news is that with this API it is not (as far as I can tell)
possible to create "true" template languages, i.e. something JSP-like that
allows discontiguous fragments of different languages. The Injection API allows
to set a (text-)prefix/suffix, but this isn't good enough if you want things
like refactoring, find usages, etc. to work properly in such fragments.

Also, Sascha Weinreuter is developing a plugin which uses the API,
although as far as I know it hasn't yet been released.


The IDEA-6 compatible version of the XPathView+XSLT plugin is based on this API,
but there's a number of injection-API related issues that include some really
bad, aka showstopper bugs that could prevent its release.

Just FYI, I'm also experimenting with an annotation-based language-injection
plugin (inspired by IDEADEV-2599). This is still in experimental stage, and I'm
not sure if it will ever see the light of the day. However, it contains some
components that may be generally useful for IDEA core. Dmitry, if you're
interested you can contact me offline.

Sascha

0
Comment actions Permalink

>> The big news in Demetra for this is the language injection API
>> (PsiLanguageInjectionHost and related classes).


The not-so-good news is that with this API it is not (as far as I can tell)
possible to create "true" template languages, i.e. something JSP-like that
allows discontiguous fragments of different languages.

:( :( :( :(.

Ahmed.

0
Comment actions Permalink

Hi Brad,

Any news on a plugin? I would like to collaborate. I have some ideas to work around the templating limitations that might allow for refactoring and searches to work more readily.

0
Comment actions Permalink

That also sounds like a good idea to me. I also would contribute in the development of such a plugin.

0

Please sign in to leave a comment.