Here is a snippet of code to put in your kakrc file (before you source plug.kak) that automatically installs plug.kak. I have done some cursory testing and it seems to work well on my computer. Any feedback/questions/issues that anyone would like to share is certainly welcome!
1 nop %sh{
2 if [ ! -d "$kak_config/plugins/plug.kak" ]; then
3 mkdir -p "$kak_config/plugins"
4 git clone https://github.com/robertmeta/plug.kak.git "$kak_config/plugins/plug.kak"
5 fi
6 }
Explanation:
(Line 1) To my knowledge, the %sh
expansions need to be given to a command, so I used the command nop
because I didn’t care about using any of the code’s output for anything. You can probably replace nop
with echo -debug
if you want its output in the debug buffer instead.
(Line 2) This checks if $kak_config/plugins/plug.kak
is a directory, where $kak_config
is Kakoune’s config directory. If it exists and is a directory, plug.kak is installed and there is nothing to do, otherwise it goes through the next steps.
(Line 3) This makes a plugins directory in case there isn’t one already. Not necessary, see edits for details.
(Line 4) This uses git to install plug.kak in the proper directory.
Edit: As was pointed out to me by Reddit user u/Sakashi_NNB on my Reddit post about this, Line 3 is not actually needed because git creates it for you when it clones plug.kak.