0

My neovim is run under Kitty with the Borland color scheme. When I start neovim my background changes. You can see the before picture here,

Before

And the after picture here,

Nvim

I've tried deleting every possible configure file I can find ~/.n?vim* and ~/.config/nvim* ~/.local/nvim. This background color is still there..

How can I find what is responsible for setting the background color when I start vim?

1

1 Answer 1

0

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,
})

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.