How to auto start(initialize) plugin on project loaded?


Hi, I'm new to Java and plugin development! 

I tried to make simple plugin with

But the tutorial is with doing some action (like keyboard action). 

In plugin.xml, (<action class="{ACTION CLASS}">) 'ACTION CLASS' is initialized after some keyboard action. but I want to make not like this, just initialize on project loaded

To make syntax highlighter and bubble tooltip on mouse hover, how can I register actions in plugin.xml file?

Comment actions Permalink

If you need to execute some code when Project is opened, you can use `com.intellij.openapi.startup.StartupActivity`:

<extensions defaultExtensionNs="com.intellij">
<postStartupActivity implementation="com.MyStartupActivity"/>

Or you can register `com.intellij.openapi.components.ProjectComponent` to create an instance of your class for each Project:



Likely, implementing a syntax highlighter via action in plugin.xml is a wrong approach.
See and

Comment actions Permalink

@Aleksey Pivovarov

Thanks! Really helpful. more question, using 'StartupActivity' is not support for each project?


Comment actions Permalink

Only one instance of `StartupActivity` will be created created, but `void runActivity(Project project);` method will be called for each project.

Comment actions Permalink

I am getting this error


java.lang.Throwable: Only bundled plugin can define com.intellij.startupActivity: PluginDescriptor(name=JHelper, id=name.admitriev.jhelper, descriptorPath=plugin.xml, path=~/workspace/github/JHelper/build/idea-sandbox/plugins/JHelper, version=0.23, package=null)


Comment actions Permalink

You're using wrong EP - it should be "postStartupActivity", not "startupActivity".


Please sign in to leave a comment.