Announcing plug.kak deferred configurations

If you’re using Kakoune builds from master, and plug.kak I’m happy to announce that now you’re able to defer plugin configuration if plugin provides a module.

For example, with fzf.kak it is meaningless to configure all these until you actually use fzf, so we can save some time by declaring a hook which will run on ModuleLoad fzf with defer "fzf" keyword of plug command:

plug "andreyorst/fzf.kak" config %{
    map -docstring 'fzf mode' global normal '<c-p>' ': fzf-mode<ret>'
} defer "fzf" %{
    set-option global fzf_preview_width '65%'
    set-option global fzf_project_use_tilda true
    evaluate-commands %sh{
        if [ -n "$(command -v fd)" ]; then
            echo "set-option global fzf_file_command %{fd . --no-ignore --type f --follow --hidden --exclude .git --exclude .svn}"
        else
            echo "set-option global fzf_file_command %{find . \( -path '*/.svn*' -o -path '*/.git*' \) -prune -o -type f -follow -print}"
        fi
        [ -n "$(command -v bat)" ] && echo "set-option global fzf_highlight_cmd bat"
        [ -n "${kak_opt_grepcmd}" ] && echo "set-option global fzf_sk_grep_command %{${kak_opt_grepcmd}}"
    }
}

This way the only configuration that plug command does on Kakoune startup is setting a mapping to call fzf-mode command, deferring everything else until needed. If plugin defines several modules, user can use different defer "module" configuration blocks to set up parts of plugins when needed.

Once Kakoune will receive new stable release these changes will go to master branch of plug.kak, until then I’m open to suggestions on further improvements.

Cool stuff!

How do I find out which modules are available in my plugins?
Consult docs of each one or is there some clever way to query it?

you can see it with :require-module command completions:

It doesn’t display modules that already loaded, but I don’t know better way yet. Maybe it should be adressed upstream. I’ve proposed to make possible for plugins to have documentation pages, where such information could be, but there’s no steps in this direction.

I’ll try to send PR to repos I know which provide plug.kak instructions to include the defer keyword if author didn’t mentioned it and it is necessary for plugin to work. My plugin readmes are updated already.