The problem
I found this bug which seems to blame
Looking at Changelog for 0.10, I do see this,
termguicolors
is enabled by default when Nvim is able to determine that the host terminal emulator supports 24-bit color.
Looking at the source code, I can see that the first case there sets termguicolors
if $COLORTERM
is set to truecolor
, or 24bit
$ echo $COLORTERM
truecolor
Well... that explains that.. And kitty sets it here to truecolor
, it's not even something you can configure.
Workarounds
These workarounds come from this issue on GitHub. One work around is to put this before the code that sets termguicolors
to true.
Lua,
vim.cmd('highlight Normal guibg=NONE guifg=NONE ctermbg=NONE ctermfg=NONE')
Or, this in vimrc
highlight Normal guibg=NONE guifg=NONE ctermbg=NONE ctermfg=NONE
The author of kitty further suggests this which requires you to manually get the bg and fg.
local bg = "#0000a3"
local fg = "#ffff4d"
local set_terminal_default_colors = "\x1b]10;" .. fg .. "\a\x1b]11;" .. bg .. "\a"
local reset_terminal_colors = "\x1b]110\a\x1b]111\a"
io.stdout:write(set_terminal_default_colors)
vim.api.nvim_create_autocmd({ "VimEnter", "VimResume" }, {
group = vim.api.nvim_create_augroup("KittySetNormalColors", { clear = true }),
callback = function()
io.stdout:write(set_terminal_default_colors)
end,
})
vim.api.nvim_create_autocmd({ "VimLeave", "VimSuspend" }, {
group = vim.api.nvim_create_augroup("KittyUnsetNormalColors", { clear = true }),
callback = function()
io.stdout:write(reset_terminal_colors)
end,
})