Closed lierdakil closed 3 years ago
vim (8.2.2891) renders italics in kitty with the default TERM of term-kitty fine for me.
vim -u NONE --cmd 'syntax on' --cmd 'highlight Comment cterm=italic gui=italic' t.sh
Where t.sh contains some comments.
In any case, this is a vim issue as kitty does not condition any behavior on the basis of TERM values. Only vim can do that. You would need to ask its developers about it.
And note that if you want to create a dump of the exact bytes a program is sending kitty, use --dump-bytes
Sorry for the non-issue. Thank you for pointing me in the right direction.
For posterity, in case someone runs into this.
This apparently happens because vim tests terminal background colour if TERM
starts with xterm
. By default, vim assumes background
is light
(with a few exceptions), so after testing it is changed to dark
if vim thinks it's actually dark (but that is determined by questionable heuristics).
This is all fine and good, but this happens long after .vimrc
is run, and setting background
triggers syntax theme reset, so any changes made in .vimrc
are lost.
The reason why alacritty wasn't affected is apparently because if TERM
doesn't start with xterm
, vim doesn't run this code path and just assumes background is light (with a couple exceptions based on TERM
value).
Ways to work around this:
background
explicitly in .vimrc
before messing with highlight
commands, e.g. set background=dark
. Or use a colour scheme that sets background
.highlight
commands from autocommand
event OptionSet background
, e.g. au OptionSet background highlight ...
FWIW, option (2) is very brittle.
Describe the bug
Italic font is not rendered in vim despite all relevant settings apparently in place; it works with other terminals or when terminfo isn't prefixed by
xterm-
. The latter makes me suspect something here falls back toxterm
terminfo.To Reproduce
Steps to reproduce the behaviour (assuming italic font is set up and working in kitty):
cterm=italic
by adding to.vimrc
:test.sh
#
Expected: commend rendered as italic Actual: comment is not rendered as italic
However, everything works as expected if terminfo is recompiled without
xterm-
prefix in the name.Screenshots
Kitty rendering italics outside vim:
Kitty not rendering italics in vim:
Other terminal (alacritty) rendering the same file opened in vim (the colour is unfortunate, sorry):
Kitty with
TERM=kitty
rendering italics in vim:Environment details
Additional context
.vimrc
line to enable italics on, say, comments:First line of dumping vim output (via
vim test.sh | tee /tmp/vim.dump
):The full dump is attached: vim.txt
Notice that running
head -n1 vim.txt
draws italic font correctly.VIM version: