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.