Fork me on GitHub
#kaocha
<
2021-09-21
>
plexus07:09:55

yeah this is the kind of thing where the whole plugin architecture hits its own limits. The config hook runs after plugins are loaded, because plugins are needed to run the hook. There is actually a mechanism for this, a plugin is really just an implementation of a plugin/-register multimethod, which is passed the current plugin chain, and returns an updated plugin chain. Typically it just adds itself, but you can add as many plugins as you want there.

plexus07:09:24

Or call the -register method of other plugins

plexus07:09:43

(defmethod plugin/-register ::my-plugin [_ plugins]
  (->> plugins
       (plugins/-register :kaocha.plugins/notifier)
       (plugins/-register :kaocha.plugins/version-filter)))

imre12:09:56

This seems to work, with one difference: I ended up having to call plugins/register without the hyphen so namespaces get loaded etc

2
plexus05:09:36

makes sense

plexus07:09:48

defplugin is really just syntactic sugar, in the end a plugin is just a map with an id and hook functions, which gets added to this list of plugins, which is then bound to plugin/*current-chain*

plexus07:09:28

this will even let you remove or reorder plugins if you so please

imre10:09:48

Thank you both! I think the register thing is going to be the solution in my case. I had been thinking about sharing a base config file but since they need to be included by path, that's a bit tricky using git deps (which is how my lib is distributed). The reader literal approach looks very neat and I might come back to it if the register one doesn't work out.