1

Please excuse my ignorance, I'm probably missing something pretty fundamental here in regards to how 256 color terminals actually work with vim.

I'm trying to create a custom color scheme for vim and upon looking at the source of some existing color schemes such as seoul256 and badwolf, I notice that they are defining their own custom color palettes that are not a part of the standard 256 colors. I was under the impression that the colors available are confined to the 256 terminal colors?

Are they simply overriding the default colors? Am I able to replace any 8-bit addressable color with my own arbitrary ones?

1 Answer 1

3

The s:rgb_map in seoul256 and all the s:bwc.* in badwolf do not define colors outside of the xterm palette. Rather, they are just there to map the finely-tuned hexadecimal colors used in GUI Vim with their closest equivalent in the xterm palette used in color terminals.

Taking seoul256 as an example, #999872 will be used for some highlight groups in GVim/MacVim while the similar but slightly darker 101 (#87875f) will be used for the same highlight groups in Vim.

Such compromises are very commonplace in the colorscheme business. If you don't like that, I see four "solutions" which all come with their own issues and compromises:

Choose all your colors from the xterm palette

This is the path I chose when I started work on my own colorscheme. The good side is that your colorscheme is more or less guaranteed to look the same in Vim and GVim but you will soon find out that the xterm palette has many shortcomings (no browns, dark colors too intense…) that will restrict your creativity.

Ask your users to change their xterm palette

Programs like colorcoke let you change the xterm palette in many crazy ways. If using a very specific palette is an important part of your concept you can make that program — or some script that you generated with it — part of the requirements for installing/using your colorscheme.

Target custom builds or Neovim running in a handful of terminal emulators

You can patch Vim so that it can use the rgb(00,00,00) notation in the terminal emulators that support that feature. That patch recently found its way in Neovim so that could be another option for you.

Build your colorscheme for 16 colors terminal emulators

…and give your users a ready made palette for customizing their terminal emulator.

So…

My preference goes to the first process because all the others have too many requirements and dependencies that make installation and support too hard.

2
  • Thanks for the in-depth explanation, that clears up a lot of my confusions. By the way, I discovered Apprentice while browsing for color schemes a few weeks ago, and its one of my favorites!
    – Anchor
    Jul 2, 2015 at 21:46
  • 2
    Note that you can write your colorscheme in such a way to use RGB colors when available (gVim, xterm customized palette), but fall back to the standard xterm colours if that's not available. Solarized does this for example. You can eat your cake and have it too! Jul 3, 2015 at 0:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.