Colorize hexadecimal colors

I’d like to do something as

add-highlighter shared/colors dynregex '(#[0-9a-f]{6})' 1:white,\1

where \1 would be the matched hex color.

Is it just possible ? I cant find any plugins that try to colorize colors.

There is also pastel. Maybe you can do something with it for Kakoune.

I’ve used this hook:

hook global WinSetOption filetype=kak %{ hook global NormalIdle .* %{
    evaluate-commands -save-regs 'a' %{ try %{
        execute-keys -draft <a-i>w"ay
        evaluate-commands %sh{ (
            color="${kak_reg_a}"
            inverted_color=$(echo "${color}" | perl -pe 'tr/0123456789abcdefABCDEF/fedcba9876543210543210/')
            printf "%s\n" "evaluate-commands -client $kak_client %{ try %{
                               echo -markup %{{rgb:${inverted_color},rgb:${color}+b}   #${color}   }
                           }}" | kak -p $kak_session
        ) >/dev/null 2>&1 </dev/null & }
    }}
}}

It echoes the color in the echo area when hovering:

image

Not exaclty a highlighter, but maybe this will help making a highlighter out of it

1 Like

This is by far the less broken thing I found about colorizing hexadecimal :smiley:

ty !

It definitely solve partialy the problem. I’ll try to implement something

both seems unreliable for different reason but thanks a lot for bringing those to me.

I still can inspire myself on some point to make on that works better

In fact, palette seems pretty much what I dream for but it is somehow broken on tmux

Okay, all was my bad. I had to update my TERM value on .tmux.conf

you may also need to update terminfo to the one shipped with Kakoune in contrib directory

i have plugin for that, which is a bit more customizable, but requires compiling a binary. GitHub - SolitudeSF/colorcol: Kakoune plugin for color previews.

1 Like

I can’t findout what it is usefull for. What’s the plus with this terminfo ?

ReedWade
March 11

I can’t findout what it is usefull for. What’s the plus with this terminfo ?

Kakoune displays colors incorrectly in tmux without this terminfo.