I have been reading through the API documentation here and As far as I can tell there are three ways to wait for the analysis to finish.
Looking at the API if get_auto_state() == AU_NONE then Analysis should be completed and if auto_is_ok() == 1 then analysis is completed. Also, from what I read auto_wait() should move forward when analysis is completed . I have tried all of these and none appear to work like I want. And I noticed that these events will be met when the IDA is pausing in part of analysis.
I mean, if there is no way to accomplish this, then I would settle for a way to sort of activate the plugin when run is called normally and then have another part run from an event listener. Both of which appear to be documented poorly.