How to create custom Live templates with Intellij plugin

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 a Live template created inside a plugin?
  • Where is the entry point for registration in the application?

Thanks.

+6
source share
1 answer

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

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

  • Copy this file to project/resources/liveTemplates

  • Create an implementation of DefaultLiveTemplatesProvider and do the following:

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

     defaultLiveTemplatesProvider implementation="com.tridium.intellij.NiagaraTemplatesProvider" 
+9
source

Source: https://habr.com/ru/post/955522/


All Articles