zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
20.25k stars 630 forks source link

NeoVim colors/theme is weird under ZelliJ #2444

Open Sebbl0508 opened 1 year ago

Sebbl0508 commented 1 year ago

zellij --version: (zellij 0.36.0) [installed via cargo install --locked zellij] stty size: 44 174 uname -av or ver(Windows): Linux fednovo 6.2.14-300.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 1 00:55:28 UTC 2023 x86_64 GNU/Linux

nvim --version:

NVIM v0.9.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

alacritty --version: alacritty 0.12.0

Further information When starting nvim in zellij, the theme is broken, it chooses the light theme, instead of dark, even tough vim.o.background is set to "dark" or vim.api.nvim_set_option('background', 'dark') is called
The issue appears on alacritty and GNOME Console (the new one).
When opening nvim, it displays everything correctly: Screenshot from 2023-05-12 09-13-29 Doing the same without zellij: Screenshot from 2023-05-12 09-13-37

I have the following in my nvim config:

function ColorPlease(color)
    color = color or "gruvbox"
    vim.cmd.colorscheme(color)

    vim.api.nvim_set_option('background', 'dark')
    vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
    vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
end
ColorPlease()

Calling lua ColorPlease() manually after NVIM is already loaded, and the broken theme is displayed, it fixes it.
I also tried deleting all my nvim directories (+ cache, + .local/share/nvim) and installing NvChad where the same issue appers. Here i can also change the theme, after the issue appears, which also fixes it (But manually changing the theme every time is not an option) I'm on Fedora 38, this issue does not appear on my other machine with Arch installed, even tough the config files should be the same (synced through git). zellij.log zellij-12.log

antistic commented 1 year ago

I had this problem and reported https://github.com/neovim/neovim/issues/22614. I think shows up for zellij because it takes a little longer to report the color than your terminal. Trying vim.schedule(ColorPlease) might work (it did for me).

Sebbl0508 commented 1 year ago

I had this problem and reported neovim/neovim#22614. I think shows up for zellij because it takes a little longer to report the color than your terminal. Trying vim.schedule(ColorPlease) might work (it did for me).

Thanks, this help, there is a short flash of light mode, then it switches. But for now it is a good workaround. Thx

jcaffey commented 1 year ago

Fix for Lazy Vim users:

init.lua

-- bootstrap lazy.nvim, LazyVim and your plugins
require("config.lazy")
require("update_colors")

Create new file: lua/update_colors.lua

vim.schedule(function()
  vim.cmd.colorscheme("catppuccin")
  vim.api.nvim_set_option("background", "dark")
end)

This will get you back to the default color scheme.

Screenshot 2023-06-03 at 8 34 08 PM
DanReia commented 1 year ago

Based on https://github.com/neovim/neovim/issues/22614, upgrading to neovim 0.9.1, fixed the issue for me.