Unusable diff highlight on NeogitStatus with the new default light colorscheme (nvim-0.10.0-nightly)
suliatis opened this issue · comments
Description
Using the default light colorscheme the diffview on the NeogitStatus view has a black or almost black bacground that makes the text in the diff context unreadable.
![Screenshot 2024-03-06 at 8 25 26 AM](https://private-user-images.githubusercontent.com/6475233/310404505-68912ce2-eccf-4160-b236-8f2c84169873.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg4NzY0NjMsIm5iZiI6MTcxODg3NjE2MywicGF0aCI6Ii82NDc1MjMzLzMxMDQwNDUwNS02ODkxMmNlMi1lY2NmLTQxNjAtYjIzNi04ZjJjODQxNjk4NzMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjBUMDkzNjAzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTRkNmJiYTE0YTY3ZDU3MmFhMDkxNzllYzI3ZTY0NjhiMzkxZmRmNTZiNDUwMDdmNTgzZTlhNDQ2YTM0MDU3MiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.4enagXPSi0WUPekUIxLIQYM4wqDkVCefh2Whl30HLs8)
Neovim version
NVIM v0.10.0-dev-2465+ga7788c2e2
Build type: RelWithDebInfo
LuaJIT 2.1.1707061634
Operating system and version
macOS 14.2.1 but probably doesn't matter
Steps to reproduce
- remove/comment the colorscheme setting
- set the background option to light
- open NeogitStatus
- toggle the diffview for any unstaged/staged file
Expected behavior
The diff panel has a light background too.
Actual behavior
Minimal config
-- comment or remove vim.cmd.colorscheme '???'
vim.opt.background = light
Meanwhile I started to use a custom colorscheme and what I realised that the colorscheme plugin must be loaded before neogit otherwise the same thing happens. I think maybe because I never set the default theme explicitly and it was loaded after neogit too.
Also I found this issue that might be related.
Makes sense - we derive colors from your colorscheme in order to make it look good without requiring every colorscheme add a bunch of highlight groups, but that does mean that if neogit is loaded before your colorscheme, it might look off. I could probably add an autocmd to help with this, though.
Oh, shoot, I already added an autocmd for ColorScheme
events. Huh. It seems to work for me.
I took another look on this and still not works with the default theme until I explicitly declare vim.cmd.colorscheme 'default'
. Then I realised that it is because I load plugins eagerly. I tried to load neogit lazily with MiniDeps.later
and it works as expected with the default theme.
So at the end it is the same for me. I need to make sure that the neogit plugin is loaded and set after the colorscheme. I have no idea why the colorscheme autocmd is not working for me.
What's quite interesting here is that Neovim loads plugins before setting default colorscheme.
@suliatis thanks for finding that out.
Lazy loading it like this solved my problem:
-- Lazy plugin manager
{
"NeogitOrg/neogit",
cmd = "Neogit", ------------ Only load Neogit when I absolutely need to
-- ...
},