Hi all! vim’s ftplugin capability allows you to stick <filetype>.vim files in .vim/ftplugin and are called whenever a buffer’s filetype matches (e.g. .vim/ftplugin/sql.vim is loaded when a buffer’s filetype is set to sql).
As explained in the FILES section of man kak, on startup Kakoune reads all of the *.kak files/scripts present in your autoload directory (or any subdirectory of it). If you have no custom autoload directory, then Kakoune falls back on the default, system-wise autoload directory, which you can probably find as /usr/share/kak/autoload on your system.
Filetype-specific scripts are to be found somewhere in the autoload directory. Have a look at any of the files provided under /usr/share/kak/autoload (e.g., python.kak) and you’ll understand how they work. These files include a detection section:
hook global BufCreate .*py %{ set-option buffer filetype python }
[Edit: I had to tweak the actual regex, because for some reason it does not show up correctly on screen.]
with a hook (type :doc hooks inside Kakoune to learn about hooks) that will fire whenever you open a file named .*py (the parameter after BufCreate is a regex).
These files also include an initialization section with all of the file-type specific stuff you want to use:
hook global WinSetOption filetype=python %{ …
This usually includes further hooks and commands for filetype-specific indentation, etc.
In sum, there is no need for a specific ftplugin subdirectory of autoload. All filetype-specific commands are activated by filetype-specific hooks.
(Of course, physically speaking, you could cram all of this in a single kakrc file, but no one would recommend it :-))