How do you organise you .config/kak folder?

Hello,

My kakoune config is getting really messy: scripts, experimental plugins and what not are everywhere.

Do some of you have nice tips and tricks on how to organize kakoune config folder ?

Another question I have is when you have a file that should not be moved arround because other script depend on an hardcoded path to the file ( let’s say an emojis.csv file used for an emoji plugin ) . What is the unix way of storing this file ? I know linux has different folder like /etc or /var, should I put it in one of those ?

1 Like

See my kakoune config https://github.com/JJK96/kakoune-config

I put experimental plugins in autoload, usually either as a single file or a single directory per plugin.
Real plugins go in the plugins directory.
The bin directory contains scripts that are used by kakoune.

Concerning files with a hardcoded path, I would put them in a resources directory in the kakoune folder or something. /etc or /var IMO is only for tools that are installed with the package manager.

I currently have 27 things in my autoload directory - some of them are plugins, some of them are custom scripts that aren’t useful enough to make into plugins, and some of them are custom configuration for plugins (like mappings for commands provided by a plugin, etc.)

I don’t really have an organisational problem with that many items, but I do have an autoload-disabled directory right beside my autoload directory, so I can move aside plugins I want to temporarily disable without deleting them or losing them completely.

As for plugin resources, when Kakoune is reading a .kak file it sets a special expansion %val{source} to the file’s absolute path. It’s a pretty common idiom for a plugin to say something like:

declare-option -hidden str my_plugin_path %sh{ dirname "$kak_source" }

…and then when it needs to use one of its resources it can say:

"$kak_opt_my_plugin_path/emojis.csv"

That way, you can move the plugin around wherever you like, and as long as you move the resources too, everything should keep working.

3 Likes

Nice ! I didn’t knew that

I also use a special bin for kak script, I think it should be default like the plugin or autoload folder, think kakoune rely so much on external script

I think it’s easier for the script author to do the my_plugin_path trick to find a custom script they need, than it is to require the end-user to place scripts in a specific directory.

I disagree. I like to have all my script in one folder and I think $sh{ myscritp } is more clean than the whole %val{source} dance. Usally the less %..{..} I have the happier I am.
Also, if the script has the potential to be call by different plugin, then putting it in more central directory makes more sense ( I’m thinking of kak-tree) . But if the script doesn’t have this potential at all, then I agree it can be more clean to have it inside the plugin folder.

Hey scr,
It does get messy pretty quickly. I picked up this from Andrey a while back. I name the file with the authors name so I never scratch my head and wonder “who and where did I get that from”.

##
# file: kakrc
# .config/kak/user/*.kak
##
evaluate-commands %sh{
  config_files="
    robertmeta.kak
    andreyorst.kak
    discuss-kakoune.kak
    orphans.kak
    occivink.kak
    teddydd.kak
    lenormf.kak
    wiki-kakoune.kak
    mawww.kak
    plugins.kak
    kowsky.kak
    grep-buffer.kak
    duncan.kak
  "

  for file in $config_files; do
    printf "%s\n" "try %{
      source '$HOME/.config/kak/user/$file'
    } catch %{
      echo -debug \"%val{error}\"
    } catch %{
      echo -debug 'blame Andreyorst for $file'
    }"
   done
}

Might help, might not. Bye :wave:


I use homebrew package manager so on each --HEAD update I need to ln -s **/**/autoload/ . the directory. The way above is just a set and forget method that works for me.

ha, interesting hack. I like the blame Andreyorst error message hehe.
Any reason you didn’t put the file directly in auto-load ?