Plugin template and good practice

Hi. Looking around various kakoune plugins, I see some of them are defining modules, some are not … Is there a plugin template I could refer to, with some explanation about how modules work and all that ?


There’s no standard plugin template, because a plugin isn’t really anything at all — it’s just a config fragment stored in a separate file instead of inline in your kakrc.

For modules specifically, they’re useful for two things in particular:

  • modules allow expensive setup costs (like dynamically generating a bunch of syntax highlighters) to be postponed until they’re needed, instead of slowing Kakoune’s startup time
  • modules allow optional dependencies between plugins, so you can have a module that’s only loaded if another plugin’s module is loaded, even if the other plugin is loaded after yours

If your plugin doesn’t have slow setup, and doesn’t have any optional dependencies, there’s no reason to use modules.

OK, fair enough, thanks for the answer.