2

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

2 Answers 2

1

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

I built on the previous answer:

vim.cmd([[
  highlight Normal guibg=NONE guifg=NONE ctermbg=NONE ctermfg=NONE
  highlight LineNr guibg=NONE ctermbg=NONE
  highlight SignColumn guibg=NONE ctermbg=NONE
  highlight EndOfBuffer guibg=NONE ctermbg=NONE
  highlight NormalNC guibg=NONE ctermbg=NONE
  highlight MsgArea guibg=NONE ctermbg=NONE
  highlight TelescopeBorder guibg=NONE ctermbg=NONE
  highlight NormalFloat guibg=NONE ctermbg=NONE
  highlight FloatBorder guibg=NONE ctermbg=NONE
]])
1
  • Welcome to Vi and Vim! What answer did you build on? How does this differ, and what are the tradeoffs? edits to this effect will improve this answer Commented Jul 10 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.