Hi everyone! After a pretty long inactivity period I’m coming back at maintaining my plugins for Kakoune. After not using my plugins for a year (or more?) I’ve almost completely forgot how they work inside, and while refreshing my memory it became apparent to me that plug.kak can be improved a bit.
I’ve re-implemented some things, deprecated some keywords, and restructured the plugin to make it a bit easier to edit it and call functions internally. It seems that it sped up a bit as well, but I didn’t benchmark it too precisely.
List of important changes:
Plugin configurations are baked into files in .build
directory located at plugin installation directory.
This is mostly done to remove a lot of loops from the code and solve some escaping problems. So from now on, plug.kak will store as minimum information at runtime as possible. I’m also thinking about storing the file’s timestamp to check modification and update build files, but this needs some more exploration, as I need to figure out a way to obtain the file from which the plug
command was called. If anyone knows if this is possible, let me know!
Deprecated the depth-sort
, no-depth-sort
keywords.
Plugins should not depend on load order, as modules are pretty common now.
Deprecated the subset
keyword.
Plugins should use modules and lazy load things with require-module
, so if repository contains several scripts, I assume that author was kind enough to wrap each script into module.
demand
keyword changed.
Preciously demand
was a hack to make defer
'red configuration happen immediately after plugin load. This had two flaws - first, if plugin has more than one module, the defer
will only work for the last defer module
block, and second, if the plugin requires it’s module inside the code, the defer
will never happen.
Now demand
works exactly the same as defer
, with the difference that it injects require-module
into configuration, to make loading of the plugin module happen immediately after plugin was sourced.
In other words, this:
plug "someauthor/someplugin" defer module %{
# module config
} demand
becomes:
plug "someauthor/someplugin" demand module %{
# module config
}
Profiling plugin load time now takes into account installation time.
Because why not?
All in all this is more a quality improvement release, there’s not new features yet. However, because many things have changed, I would like to request testing this before I merge it into main branch.
You can try out new version by checking out the development
branch. If you’re lazy, you can add this snippet to your kakrc and it will do the work for you:
# bootstrap the plugin manager
evaluate-commands %sh{
plugin_dir="$kak_config/plugins"
mkdir -p $plugin_dir
[ ! -e "$plugin_dir/plug.kak" ] && \
git clone -q https://github.com/andreyorst/plug.kak --branch develop "$plugin_dir/plug.kak"
printf "%s\n" "source '$plugin_dir/plug.kak/rc/plug.kak'"
}
Thanks in advance!