1 hour ago · Writing · hide · 0 comments

I wanted to conditionally add the current buffer’s word count to Kakoune’s modeline. I thought I’d write down how I got this working in case you’re new to Kakoune or you’re interested to learn a bit more about how Kakoune and the shell interact with each other. Conditionally adding this conditional functionality I only care about the word count in some of my projects. So, for now, instead of autoloading this functionality globally, I’ll add it to a .kakrc in the root of the projects where I want this. In my user’s Kakoune configuration file I load project-specific configuration like this: evaluate-commands %sh{ local_kak_config="$(pwd)/.kakrc" sh -c "echo 'try %{ source \"$local_kak_config\" } \ catch %{ echo -debug cannot autoload \"$local_kak_config\" }'" _ {} \; } The full script I’ll take you through this line by line. But before I do, here’s the entirety of the script: declare-option -hidden str modeline_buf_word_count_formatted '' set-option -add global modelinefmt…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.