I'm using vim in tmux for writting my gemtext. But I scratched my head to find out a solution to have correct color.
So this what works for me :
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"