Live templates plugin

Hi guys,

I'm trying to create a plugin for Bootstrap3 live templates. There already exists on for PHP storm, but it doesn't work for IntelliJ. So here's my approach. However, mine also doesn't work :-)

I have to plugin in Git, here: https://github.com/bodiam/intellij-bootstrap3

So, what I have is a BootstrapTemplatesProvider:

    public String[] getDefaultLiveTemplateFiles() {         return new String[]{                 "resources/liveTemplates/bootstrap3",                 "liveTemplates/bootstrap3",                 "bootstrap3",                 "resources/liveTemplates/bootstrap3.xml",                 "liveTemplates/bootstrap3.xml",                 "bootstrap3.xml",         };     }


With many versions of the live templates, though I guess the 'liveTemplates/bootstrap3' is the only correct one. But having only that also doesn't work.

In the plugin.xml, I registered the TemplatesProvider:

  <extensions defaultExtensionNs="com.intellij">     <!-- Add your extensions here -->       <defaultLiveTemplatesProvider implementation="intellij.plugin.bootstrap3.BootstrapTemplatesProvider"/>   </extensions>


And my bootstrap3.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?> <templateSet group="bootstrap3">     <template name="bs3-label:default" value="&lt;span class=&quot;label label-default&quot;&gt;Default&lt;/span&gt;" toReformat="false" toShortenFQNames="true">         <context>             <option name="HTML_TEXT" value="true" />             <option name="HTML" value="true" />         </context>     </template> </templateSet>


I've put a breakpoint in my TemplatesProvider, I see that it's loaded, but when I create a new HTML file in my test project, and type bs3, and press Cmd+J, nothing happens.

What am I missing here?

Thanks, Erik

22 comments
Comment actions Permalink

Without actually trying to load your project, but it seems "/resources/" is not defined as source/resource root in your module and thus not packaged.

0
Comment actions Permalink

Argh. You're very right. I forgot it's running from the out directory, instead of the src. Thanks!

0
Comment actions Permalink

PS: any idea why this plugin doesn't work in IntelliJ, but it does work in PHPStorm: https://github.com/JasonMortonNZ/bootstrap3-phpstorm-plugin

0
Comment actions Permalink

It works for me in IJ Ultimate 14. What version/edition are you trying?

0
Comment actions Permalink

I'm using IntelliJ 13.1.4 on Mac. When I install the plugin and try to use the shortcuts, nothing happens. Also check the comment on the plugin page here: https://plugins.jetbrains.com/plugin/7390?pr=phpStorm, where a user has the same problem.

0
Comment actions Permalink

Plugin is visible and enabled in "Settings->Plugins"? Do you see "Bootstrap3" category in Editor->Live Templates? Please make sure to run IJ with JDK 1.7 since plugin was compiled with it. It works for me running 13.1 snapshot Ultimate Edition.

0
Comment actions Permalink

Hi Yann,

This is so weird. I have the plugin installed, but the live templates group doesn't show Bootstrap 3. Really no idea why it doesn't work. 'My' version of the plugin does work however :S

Screen Shot 2014-09-30 at 18.05.57.png
Screen Shot 2014-09-30 at 18.05.48.png

0
Comment actions Permalink

I assume you tried to de- and reinstall already?


0
Comment actions Permalink

It's something I should have mentioned, but yes. I haven't tried invalidating caches or removing directories yet though, but I was hoping that wouldn't be necessary...

0
Comment actions Permalink

Actually, I tried again, and also my version of the plugin is not working, even though it was working when developing it! I'll start uninstalling plugins (even though I don't think I installed any...)

0
Comment actions Permalink

Okay, I:

- Invalidated caches
- Removed all the directories mentioned here: http://www.jetbrains.com/idea/webhelp/project-and-ide-settings.html
- Reinstalled the plugin.

Still doesn't work, the live templates aren't added to the list..... Installing IntelliJ 14 now. I'm going crazy :-)

0
Comment actions Permalink

you could verify idea.log if plugins are correctly loaded on startup or if there are any errors

0
Comment actions Permalink

I think I finally found it: apparently, I compiled the plugin using IntelliJ SDK. Which is version 1.7. However, IntelliJ itself(??) runs on JDK 1.6. So I got this error in IntelliJ 14:

com/intellij/plugin/bootstrap3/Bootstrap3TemplatesProvider : Unsupported major.minor version 51.0 [Plugin: nl.jworks.intellij.bootstrap3]


However, in IntelliJ 13 I never saw this error. No blinking exclamation mark, nothing.

So, two questions:
- How can I compile it using JDK 1.6?
- Why is didn't this error show on IntelliJ 13?

0
Comment actions Permalink

I think I also fixed the JDK issue, I had no JDK's installed yet, so I only added 1.6. After that, IntelliJ asked me which SDK to use for the plugin SDK, so I choose 1.6 (only option available).

I created a new version of the plugin, but after uploading, I got this message:

"Thank you. You plug-in has been submitted for moderation, and will be processed within two working days."

Why is this? (Adding a new plugin is instant, but updating/fixing it takes two days?)

0
Comment actions Permalink

Ok, thanks for confirming. Exception is swallowed intentionally here (com.intellij.codeInsight.template.impl.TemplateSettings#loadDefaultLiveTemplates) and thus only logged.

0
Comment actions Permalink

Erik, moderation is needed to check that plugin is compatible with the latest IntelliJ IDEA version - new versions can introduce API changes.

Victoria

0
Comment actions Permalink

Hi Victoria, thanks for the answer, but why doesn't this apply to new plugins then? Plus, isn't it the responsibility of the plugin developer to do this? Now it takes 2 (working?) days to update the plugin, and personally, I think that's quite long.

Also, can't the process be automated? Now I first have to create a jar, browse to the website, fill in details, etc. IMO, it would be handier to have a Gradle/Maven task which would enable such a thing.

0
Comment actions Permalink

Thanks, but in other words, it's not high on the backlog (16 months ago??)

0
Comment actions Permalink

Apparently there's not too many 3rd party plugin devs pushing out weekly releases of their plugins ;-)

0
Comment actions Permalink

Chicken and egg problem? ;-)

Seriously though, uploading it by hand is something which would be nice if it could be automated, but I can work around that, or automate it myself.
Having to wait two days is a bigger issue. For comparisson, most of my customers go to production multiple times per day, so I find it hard to understand why a trivial plugin has this wait time.
If compatibility is an issue, automate it. I understand there are many things to do, and many things to improve, but this is a thing which seems easy enough to implement, or am I assuming too much here?

0
Comment actions Permalink

I suspect that if you release new versions very often, you will annoy whoever checks the compatibility and you will be granted an exception from the process - most of my plugins can be updated without waiting.  ;)

0

Please sign in to leave a comment.