thomascarpone

bear and fish - colorscheme for kakoune

fish

The common dab is an edible flatfish

dabby cute-y fishy

dab

dry

The everforest colorscheme was my favorite one for as long as I can remember (can't remember anything), and I was loving it.
Its pastel colors are smooth on the eyes and make me feel like I'm in a tiny greeny forest.

However, I noticed my eyes were drier and causing me pain after a long day of work (i don't work this hard).
And since my main hobby is closely related to my work (nerding), I'm even drier and pain-er at the end of the day.

Thus, I did not change colorscheme.
I knew. I was at a crossroads. I had to create my own or keep rolling the green.
And even though I could create the best colorscheme ever (no), I have not.
I didn't want to annihilate every single neovim 'schemes (would cry if i had to manage plugin highlights).

stupid

Even though I have +256G of hard drive space and 8G of RAM, I still have the urge to spare resources.
I write my personal projects in C99 or as POSIX shell scripts, so they're compatible with all Unix distributions.
I minimize their memory size and how much strain they put on one's system, even when unnecessary (always is, small-ass projects).

My neovim config plugins' count kept decreasing. Where people tend to add functionalities, I love to go as minimal as I can.
I've stopped using LSPs (productivity). No plugin if it can be done without.
Making the best use of what is available to me (meh-use, really).

When I came across this amazing video, I knew I had to give Kakoune a try.
It's a selection first, motion-verb modal editor, with keybindings close to vim's.
One will use a combination of POSIX shell scripting and kakoune's own minimal internal language to configure their editor.

NB: I will write another post about Kakoune and how its "minimalism" embraced mine, for the better.

That's a call. I answered. I jumped right in. Without a thought. As always.
Plus, I had the urge to absolutely destroy my sanity and my productivity (they weren't that good).

Here I was, having to learn everything back (stars twinkle).
I started writing small plugins to replace the simple mechanisms I was used to in neovim.
I installed an everforest port.
Soon, I had a minimally viable configuration for kakoune and was happily rocking with it.

{,da}bruin

This article is about bear and flatfish, not my posix-shell-masochism.
While I was browsing projects on sourcehut, I stumbled across the bear.
The wonderful vim-bruin project.
A colorscheme only using terminal attributes. That's an incredible idea.

It inspired me to create my very own colorscheme: Dim, Accent, Bold, Reverse, Underline, Italic, Nothing, DABRUIN.
The idea was to ~port~ vim-bruin to kakoune, while still making it my own.

Even though the "no color" policy is really enticing, I went with an accent color.
I use a white-ish foreground and a black-ish background. Two shades of grey for extra information.
Sane defaults, huge contrast, and customization in mind.
The accent can be defined through a kakoune option.
I couldn't use the dim attribute directly since it collides with others on certain terminal implementations (see this thread).

The colorscheme calculates dim values each time it is loaded, using :

# dim a color value expressed with the syntax rgb:RRGGBB
calculate_dim() {
   printf "$1" | cut -d: -f2 | fold -b2 |
       while read -r hex; do
           base10="$(printf '%d' "0x${hex}")"
           printf '%02x' "$((base10 * 5 / 9))"
       done | xargs printf 'rgb:%s'
}

Compatibility (yada yada). I wanted to avoid using bc for the calculation, because I'm not sure it is available by default (I couldn't bother to check).
I'm pretty sure the fold command is installed by default, so it's all good (I couldn't bother to check x2).
The 5/9 ratio is arbitrary. I found it to produce great results with dabruin's base colors.
The whole thing could, and might, be replaced by an awk script. It just seemed funnier this way.

Since the main color can be defined using a simple kakoune option, I've added a small code snippet to my kakrc.
Each time a new server is created, the accent color changes to a random value.
One can also force the color change across all server's clients using the dabruin-accent-color.

# dabruin.kak does not declare the dabruin_accent option
declare-option str dabruin_accent
define-command -params 0 dabruin-random-accent %{
    set-option global dabruin_accent %sh{
       printf 'rgb:%s' "$(tr -dc 'a-fA-F0-9' </dev/urandom | head -c 6)"
    }
    colorscheme dabruin
}
dabruin-random-accent

Another idea would be to use a str-list option to select the accent from a pool of user-defined colors.

screenshots

out of the box colors

screenshot_021101

random green color, shell script, selection

screenshot_013401

random magenta color, C file, multi-selection

screenshot_013621

hjkl

Didn't have a title for the last section, and "conclusion" seemed too formal.
I'm happy with how the colorscheme turned out. It can be customized without needing lots of options.

This was supposed to be my first blog post, presenting one of my projects.
Turns out, I talked about me and my life.
However, I enjoyed writing it, and I doubt posting it will be as pleasant.

project, copyright and licenses

Link to the repo.
All copyright notices and acknowledgments can be found here.
This project is licensed under The Unlicense.

let's talk !

I would love for us to talk, now that you're done with this post :)

# str -> rot13 -> base64 decode => mail
echo 'qTuioJSmYaEynKuynKWuDUA0LKW0oJScoP5wo20X' |
   tr 'a-zA-Z' 'n-za-mN-ZA-M' |
   base64 -d
Thoughts? Leave a comment

Comments
  1. Seb — Dec 5, 2023:

    Good job with the article. I don't think i got all the references, but the tone and the content are very enjoyable to anyone interested in this topic. One can feel you really put thoughts, humour and energy in the making of this article. Well done. Keep going!