kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.41k stars 980 forks source link

vim doesn't recognise that background is dark #1565

Closed ghost closed 5 years ago

ghost commented 5 years ago

until I changed the color scheme in my kitty.conf, vim was starting with a dark background.

I changed the color scheme in kitty.conf, and it's still a dark color scheme, but vim now starts with a light background. I know I can do set background=dark to force vim to use the dark-backgrounded theme, but it's interesting to me why this isn't the default anymore, and how I can make it the default again.

kovidgoyal commented 5 years ago

What color vi uses as its background depends on vim's config, not kitty.

ntrrgc commented 6 months ago

What color vi uses as its background depends on vim's config, not kitty.

This is not entirely true. Although Vim has some terminal-specific defaults, there is an OSC to query the background and foreground colors of the terminal, and Vim makes use of it.

src/termdefs.h
100:    KS_RBG, // request background color
214:#define T_RBG   (TERM_STR(KS_RBG))  // request background RGB

src/term.c
479:    {(int)KS_RBG,   "\033]11;?\007"},

The following is a small Python script that makes those queries and waits for a response. In GNOME Console, xterm, VS Code or Konsole, it will print the background and foreground, whereas in terminals not supporting it (like Kitty as of now) it will be stuck waiting.

https://gist.github.com/ntrrgc/fc47b416bff68ebc05883ec733c8a7b8

kovidgoyal commented 6 months ago

kitty most definitely supports it. screenshot

ntrrgc commented 6 months ago

You're right, and I have checked the script again and it also runs in Kitty :/

Now I'm wondering what is making Vim stay in the wrong mode then...

kovidgoyal commented 6 months ago

There is a FAQ entry on vim in the kitty FAQ, follow it and you should be fine.

ntrrgc commented 6 months ago

I see... Thanks for the pointers.