我正在尝试使用来自 https://github.com/kaicataldo/material.vim
的 vim-material 主题到目前为止我尝试过的:
在我的 .tmux.conf 中 我都试过了
set -g default-terminal "screen-256color"
和
set -g default-terminal "xterm-256color"
我也尝试过
TERM=screen-256color-bce tmux
我可以在这里回显 $TERM 并给出正确的结果。但我也尝试过在打开 nvim 之前使用
export TERM=xterm-256color
或 export 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 会话以确保它反映
相关应用程序和操作系统的版本
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://www.cyfyifanchen.com/blog/neovim-true-color
set-default colorset-option -ga terminal-overrides ",xterm-256color:Tc"
我在 neovim 中运行
h: checkhealth
,当我在 tmux 会话中使用 neovim 时,我只收到一条错误消息。检查健康消息提供了唯一对我有用的解决方案。
这就是它所说的:
- WARNING: Neither Tc nor RGB capability set. True colors are disabled. |'termguicolors'| won't work properly.
- ADVICE:
- Put this in your ~/.tmux.conf and replace XXX by your $TERM outside of tmux:
set-option -sa terminal-overrides ',XXX:RGB'
- For older tmux versions use this instead:
set-option -ga terminal-overrides ',XXX:Tc'
set-option -ga terminal-overrides ",xterm-256color:Tc"
中的 .tmux.conf
和 alias tmux="TERM=screen-256color-bce tmux"
中的 .bashrc
使用 Windows 终端在 Windows WSL2 中为我工作。现在我可以在 tmux 中使用 vim :)
只需更改 shell 配置文件中的
TERM
环境变量,在我的例子中是 .zshrc
,即:
# Path Variables
export TERM='xterm-256color'
export EDITOR='nvim'
export VISUAL='nvim'
重新加载终端并重新加载 tmux 或终止 tmux-server 并检查:
> echo $TERM
对我来说,它是这样工作的,用
.tmux.config
书写
set -ga terminal-overrides ",xterm-256color:Tc"
由于我使用旧版本的 TMUX(不支持所有颜色),这是我的解决方案:
-- Set colorscheme
vim.o.termguicolors = false
vim.cmd [[colorscheme default]]