Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neovim background is broken if in tmux #6869

Closed
ZirixCZ opened this issue Apr 18, 2023 · 14 comments
Closed

neovim background is broken if in tmux #6869

ZirixCZ opened this issue Apr 18, 2023 · 14 comments

Comments

@ZirixCZ
Copy link

ZirixCZ commented Apr 18, 2023

System

OS: macOS
Version: Version 0.11.0 (8dbaa0b)

Neovim's background is broken while in a tmux session.

If I start nvim from a tmux session while running in alacritty, the background is broken.

Neovim running inside of alacritty without tmux:
Screenshot 2023-04-18 at 21 28 25

Neovim running inside of tmux inside of alacritty:
Screenshot 2023-04-18 at 21 26 57

Neovim running inside of tmux inside of kitty (to demonstrate it is not the fault of tmux):
Screenshot 2023-04-18 at 21 30 28

Configurations

nvim

vim.cmd("colorscheme nightfox")

tmux

set -g base-index 1       # Start numbering windows at 1, not 0.
set -g pane-base-index 1  # Start numbering panes at 1, not 0.
bind -n C-t new-window
bind -n C-PgDn next-window
bind -n C-PgUp previous-window
bind -n C-S-Left swap-window -t -1\; select-window -t -1
bind -n C-S-Right swap-window -t +1\; select-window -t +1
bind -n C-1 select-window -t 1
bind -n C-2 select-window -t 2
bind -n C-3 select-window -t 3
bind -n C-4 select-window -t 4
bind -n C-5 select-window -t 5
bind -n C-6 select-window -t 6
bind -n C-7 select-window -t 7
bind -n C-8 select-window -t 8
bind -n C-9 select-window -t:$
bind -n C-M-w kill-window
bind -n C-M-q confirm -p "Kill this tmux session?" kill-session
bind -n F11 resize-pane -Z

set -g status-style "bg=default"
set -g window-status-current-style "bg=default,reverse"
set -g window-status-separator ''  # No spaces between windows in the status bar.
set -g window-status-format "#{?window_start_flag,, }#I:#W#{?window_flags,#F, } "
set -g window-status-current-format "#{?window_start_flag,, }#I:#W#{?window_flags,#F, } "

set -g mouse on

set -g default-terminal 'xterm-256color'
set -as terminal-overrides ',xterm*:Tc:sitm=\E[3m'

I tried running with vanilla tmux settings. The result was the same.

alacritty

import:
  - ~/.config/alacritty/catppuccin/catppuccin-mocha.yml

font:
  normal:
    family: "JetBrainsMonoNL Nerd Font Mono"
    style: Regular

  bold:
    family: "JetBrainsMono Nerd Font Mono"
    style: Bold

  italic:
    family: "JetBrainsMono Nerd Font Mono"
    style: Italic

  bold_italic:
    family: "JetBrainsMono Nerd Font Mono"
    style: Bold Italic

  size: 14

  env:
    TERM: xterm-256color

epilog

I've been trying to find a fix for this for quite a while now, but nothing seemed to have worked. Perhaps this thread helps somebody in the future.

@ZirixCZ
Copy link
Author

ZirixCZ commented Apr 19, 2023

I tested it on Fedora 38 today, this bug is present there as well.

@pbgc
Copy link

pbgc commented Apr 19, 2023

I tested in MacOS (I always use tmux) and the two are exactly the same ... no problem...

Captura de ecrã 2023-04-19, às 14 00 51

@pbgc
Copy link

pbgc commented Apr 19, 2023

@ZirixCZ I have this on my .tmux.conf:

set -g default-terminal "xterm-24bit"
set -g terminal-overrides ',xterm-24bit:Tc'

@pbgc
Copy link

pbgc commented Apr 19, 2023

@ZirixCZ
just tried your settings and with:

set -as terminal-overrides ',xterm*:Tc:sitm=\E[3m'

I have the same problem!

try to change it to:

set -ga terminal-overrides ",xterm-256color*:Tc"

EDIT
Use this and will not have the problem:

# set 256 color
set -g default-terminal "tmux-256color"
# tell Tmux that outside terminal supports true color
set -ga terminal-overrides ",xterm-256color*:Tc"

or use 24bit setting I posted before

@ZirixCZ
Copy link
Author

ZirixCZ commented Apr 19, 2023

I tested in MacOS (I always use tmux) and the two are exactly the same ... no problem...

Captura de ecrã 2023-04-19, às 14 00 51

Considering your background looks identical with my "broken background" situation, might I ask you to change your background to something custom and testing, if it still looks the same? if you don't have any custom background in neovim, there is no background to be broken.

This is what I use, if would you like to test it with it:

        ... in plugin file
	use("EdenEast/nightfox.nvim")
	... in a set file
	vim.cmd("colorscheme nightfox")

I tried to put what you suggested into my tmux config, but it did not help. Might I ask what version of alacritty and tmux are you using

@pbgc
Copy link

pbgc commented Apr 19, 2023

@ZirixCZ my background is correct and from Tender Theme (https://github.com/jacoborus/tender.vim)

I tried your settings and I had your problem ... just try the changes I told you!

@pbgc
Copy link

pbgc commented Apr 19, 2023

sorry ... only now read that the changed did not help.
I have alactritty 0.12 and tmux 3.3a

@pbgc
Copy link

pbgc commented Apr 19, 2023

@ZirixCZ Sorry... I made some confusion here ... (because when I tried your settings I used helix and not nvim .. and I have a different theme in helix).

Tried again and with mine or your settings I don't have the problem you described in MacOS! (at least with Tender Theme)

@ZirixCZ
Copy link
Author

ZirixCZ commented Apr 19, 2023

Also, for some reason, when I put the configurations you use into my tmux config file, it glitches out and every letter I type is there multiple times. Nevertheless, it did not fix the background issue for me. I upgraded to alacritty 0.12 now and the issue is still there. I installed it through brew.

Edit:

@ZirixCZ Sorry... I made some confusion here ... (because when I tried your settings I used helix and not nvim .. and I have a different theme in helix).
Tried again and with mine or your settings I don't have the problem you described in MacOS! (at least with Tender Theme)

Good, meaning the issue might not be due to tmux after all.

@pbgc
Copy link

pbgc commented Apr 19, 2023

@ZirixCZ found this .. maybe it will help:

https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6

I can send you my alacritty.yml, .tmux.conf and init.vim if you want to check them

@ZirixCZ
Copy link
Author

ZirixCZ commented Apr 19, 2023

I can send you my alacritty.yml, .tmux.conf and init.vim if you want to check them

if you could

@pbgc
Copy link

pbgc commented Apr 19, 2023

@ZirixCZ I remembered that I had to add terminfo entries ... I did it long time ago ...

https://gpanders.com/blog/the-definitive-guide-to-using-tmux-256color-on-macos/

EDIT: I did it for 24bit also .. and that's what I use.

@pbgc
Copy link

pbgc commented Apr 19, 2023

@ZirixCZ I think your problem is around terminfo ...

tmux/tmux#696

I can send you my conf .. but you will have the same results. Follow the instructions on this link!

@ZirixCZ
Copy link
Author

ZirixCZ commented Apr 19, 2023

My issue got fixed by adding the following flag into~/.tmux.conf

set-option -ga terminal-overrides "alacritty:Tc"

The override should be the string you get from echo $TERM in a session that can start a working nvim. In my case, running nvim in alacritty with no tmux works, hence why I put alacritty there, as that's what echo $TERM outputs when in that session. Interestingly, when in tmux, echo $TERM outputs screen-256color, not alacritty as I would expect. It works though.

@ZirixCZ ZirixCZ closed this as completed Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants