7

I want to create a custom Live Template that will be available with my plugin. I know how to create custom Live Templates using the Settings dialog, but I want to be able to distribute the Live Template as part of my plugin:

  • How is the Live Template defined within the plugin?
  • Where is the entry point to register it with the application?

Thanks.

weakish
  • 28,682
  • 5
  • 48
  • 60
SimpleSam5
  • 3,280
  • 2
  • 16
  • 13

1 Answers1

9

using 12.1.5 I was able to accomplish this after looking at the groovy plugin source.

  1. Go ahead and create your template using the settings dialog. It will store the resulting xml file somewhere under %home%/.Ideawhatever/config/templates in group_name.xml

  2. Copy this file into project/resources/liveTemplates

  3. Create an implementation of DefaultLiveTemplatesProvider and implement as follows:

     @Override
     public String[] getDefaultLiveTemplateFiles()
      {
         return new String[] {"liveTemplates/group_name"};
      }
    
  4. add the following under extensions in your plugin.xml

    defaultLiveTemplatesProvider implementation="com.tridium.intellij.NiagaraTemplatesProvider"
    
AdrieanKhisbe
  • 3,899
  • 8
  • 37
  • 45
SimpleSam5
  • 3,280
  • 2
  • 16
  • 13
  • Regarding the user template directory location: In IntelliJ 14 on OS X, the file is in Users ▸ $you ▸ Library ▸ Preferences ▸ IntelliJIdea14 ▸ templates – Dan Tanner Feb 12 '15 at 19:48
  • It's worth nothing that you should mark resource folder as **Sources Root** or **Resources Root** (context-menu -> Mark Directory As -> Resources Root) – Alireza Mirian Aug 24 '15 at 09:34