zellij icon indicating copy to clipboard operation
zellij copied to clipboard

NeoVim colors/theme is weird under ZelliJ

Open Sebbl0508 opened this issue 1 year ago • 4 comments

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

Sebbl0508 avatar May 12 '23 07:05 Sebbl0508

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).

antistic avatar May 17 '23 14:05 antistic

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

Sebbl0508 avatar May 18 '23 15:05 Sebbl0508

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

jcaffey avatar Jun 04 '23 01:06 jcaffey

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

DanReia avatar Jun 04 '23 12:06 DanReia