Neovim 在 tmux 中丢失配色方案。我看到的所有过去的解决方案都不适合我

Neovim losing colorscheme when in tmux. All past solutions I see don't work for me

我正在尝试使用来自 https://github.com/kaicataldo/material.vim

的 vim-material 主题

下面是我在 tmux 中 运行 neovim 时发生的情况

下面应该是这样的

到目前为止我尝试了什么:

在我的.tmux.conf 我都试过了

set -g default-terminal "screen-256color"

set -g default-terminal "xterm-256color"

我也试过了

TERM=screen-256color-bce tmux

我可以在这里用正确的结果回显 $TERM。但我也尝试在打开 nvim

之前用 export TERM=xterm-256colorexport TERM=screen-256color 手动设置它们

这是我的 init.vim

let g:material_theme_style = 'ocean'
colorscheme material
set background=dark
set t_Co=256
set termguicolors

我试过设置和取消设置这些。 取消设置 termguicolors 是最糟糕的,主题只是没有工作,它给了我默认 vim 外观

我也 运行 tmux 作为 tmux -2 我还应该提到我在 tmux.conf 中更改任何内容后终止 tmux 会话以确保它反映

相关应用的版本和os

nvim v0.4.3
tmux 3.0a
iTerm2 3.3.9
macOS mojave 10.14.6

编辑:

我已经尝试清除所有 tmux 插件和 nvim 个插件,只在我的 tmux 配置中保留默认终端

这是我的 init.vim 文件中剩下的内容

call plug#begin('~/.config/nvim/plugged')

Plug 'kaicataldo/material.vim'
call plug#end()

set termguicolors
let g:material_theme_style = 'default'
colorscheme material

我还尝试下载旧版本的 tmux。 2.5,还是不行。

我删除了我所有的 tmux 插件和 nvim 个插件并重新安装了 material.vim 所以我确定插件中没有任何冲突

找到解决方案。这篇文章帮助了我: https://cyfyifanchen.com/neovim-true-color/

set-default colorset-option -ga terminal-overrides ",xterm-256color:Tc"
.tmux.conf 中的

set-option -ga terminal-overrides ",xterm-256color:Tc".bashrc 中的 alias tmux="TERM=screen-256color-bce tmux" 在 windows WSL2 中使用 windows 终端为我工作。现在我可以在 tmux 中使用 vim :)