I want to know if it's possible to detect available colors in terminal which vim was called, so I could select different colorschemes for each color situation.
This is different from checking &t_Co
variable. Sometimes I open a vim with 8 colors, and can set t_Co=256
to use some colorschemes, but sometimes (Like in Terminal.app in mac), setting this variable doesn't throw an error but the t_Co
isn't changed because Terminal.app's color limit is 16.
Fact is: I only know this limit by experience, I would like to know if it's possible to know this value from calling a function (if terminal_supports > 256)
or something like that.
Can I do it using just viml functions, or I would need to create some bash scripts and call them from vimrc for example? I would like to have this information in Linux, Mac and Windows (also, using Cygwin).
(If I, for some reason, can't get this information from the system, is there a table or in vim help some information about different terminals and their color capabilities? If so, then I could create a hash table with all terminals and ther colors capabilities.)
Another try: some information is here, if you haven't found it already, including informative link at bottom of the linked page:
256_colors_in_vim
So far as I know Vim gets the t_Co number from termcap. So if you can get value from termcap to accurately reflect max colors supported then you're set. I think that's what the info in linked page does, at least for 256 color terms. . .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With