echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
5.35k stars 192 forks source link

mini.base16: support default cterm color map when no termguicolors #456

Closed Reisen closed 1 year ago

Reisen commented 1 year ago

Contributing guidelines

Module(s)

base16

Description

I'm currently using the base16 mini module because it has a fairly comprehensive set of highlight rules for plugins that I rely on. However, I am using a base16 (256 color) theme for my terminal with termguicolors turned off, this gives me consistent colors accross all terminal applications.

The current base16 module however (at least as I understood the docs) is geared towards termguicolors and only attempts to choose close color codes for cterm fallback, rather than providing the actual base16 color codes for a properly configured base16 terminal.

I am working around this with something that is a bit of a hack:

                base16 = {
                    plugins = { default = true },

                    -- No effect in termguicolors so values don't matter, but must be set.
                    palette   = {
                        base00 = "#000000",
                        base01 = "#000000",
                        base02 = "#000000",
                        base03 = "#000000",
                        base04 = "#000000",
                        base05 = "#000000",
                        base06 = "#000000",
                        base07 = "#000000",
                        base08 = "#000000",
                        base09 = "#000000",
                        base0A = "#000000",
                        base0B = "#000000",
                        base0C = "#000000",
                        base0D = "#000000",
                        base0E = "#000000",
                        base0F = "#000000",
                    },

                    -- Assign bases to the official extended base16 color codes.
                    use_cterm = {
                        base00 = 0,
                        base01 = 18,
                        base02 = 19,
                        base03 = 8,
                        base04 = 20,
                        base05 = 7,
                        base06 = 21,
                        base07 = 15,
                        base08 = 1,
                        base09 = 16,
                        base0A = 3,
                        base0B = 2,
                        base0C = 6,
                        base0D = 4,
                        base0E = 5,
                        base0F = 17,
                    }
                },

The gui colors don't matter because I don't run in gui mode anyway so I set them all black, and the use_cterm being set to terminal color codes makes this code here properly assign the right terminal colors as I would have expected the defaults to be (see this base16-shell script example to see official the termcolor <-> base assigns).

With this I can change my terminal-wide theme and vim changes as expected (along with all other terminal apps). This seems like an intended way to use base16 in general so I wanted to see if this default base to termcolor map could be supported by the plugin itself, perhaps through use_cterm = 'default' or some other hint.

echasnovski commented 1 year ago

Thanks for suggestion!

The current base16 module however (at least as I understood the docs) is geared towards termguicolors and only attempts to choose close color codes for cterm fallback, rather than providing the actual base16 color codes for a properly configured base16 terminal.

Yes, this sounds reasonably correct.

The suggested approach here is exactly as you have already done: supply use_cterm as table with cterm color codes that suit you best. It already can be both boolean or table, so I don't want to introduce another conditional logic to it.

Closing as not planned.