vim颜色方案不渲染背景色

vim颜色方案不渲染背景色,vim,terminal,macvim,hyper,Vim,Terminal,Macvim,Hyper,尝试解决方案:添加export TERM=xterm-256color到.bashrc和.zshrc,并添加设置t_Co=256到.vimrc,如其他问题的解决方案中所述 是,我使用的配色方案既支持gui,也支持终端 我主要使用macos和hyper.app,但是类似的情况在Terminal.app上同时发生,所以我想这不是模拟器的问题 另一个堆栈溢出问题有点奇怪: 将此添加到我的.vimrc: if &term =~ '256color' " disable Background

尝试解决方案:添加
export TERM=xterm-256color
.bashrc
.zshrc
,并添加
设置t_Co=256
.vimrc
,如其他问题的解决方案中所述

是,我使用的配色方案既支持gui,也支持终端

我主要使用macos和
hyper.app
,但是类似的情况在
Terminal.app
上同时发生,所以我想这不是模拟器的问题

另一个堆栈溢出问题有点奇怪: 将此添加到我的
.vimrc

if &term =~ '256color'
  " disable Background Color Erase (BCE) so that color schemes
  " render properly when inside 256-color tmux and GNU screen.
  set t_ut=
endif
set background=dark
highlight Normal ctermbg=NONE
highlight nonText ctermbg=NONE
将我的vim背景更改为深灰色(我不知道这是从哪里来的),但删除它会将其更改回我的终端背景色

我会接受任何解决方案(因为我受够了,让它工作起来),这样我就可以使用
color Picker.app
mac vim gui
获取十六进制颜色,并可以在每次我决定更改主题时将其强制设置为vim背景

我的所有配置文件:

我也使用
tmux
,但颜色与有无
tmux
的颜色相同

编辑:
:scriptnames的输出

  1: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/vimrc
  2: ~/.vimrc
  3: ~/.vim/autoload/plug.vim
  4: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/filetype.vim
  5: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/ftplugin.vim
  6: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/indent.vim
  7: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/syntax/syntax.vim
  8: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/syntax/synload.vim
  9: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/syntax/syncolor.vim
 10: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/ftoff.vim
 11: ~/.vim/bundle/Vundle.vim/autoload/vundle.vim
 12: ~/.vim/bundle/Vundle.vim/autoload/vundle/config.vim
 13: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/syntax/nosyntax.vim
 14: ~/.vim/plugged/nemo/colors/nemo-dark.vim
 15: ~/.vim/bundle/vim-tmux-navigator/plugin/tmux_navigator.vim
 16: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/plugin/getscriptPlugin.vim
 17: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/plugin/gzip.vim
 18: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/plugin/logiPat.vim
 19: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/plugin/manpager.vim
 20: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/plugin/matchparen.vim
 21: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/plugin/netrwPlugin.vim
 22: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/plugin/rrhelper.vim
 23: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/plugin/spellfile.vim
 24: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/plugin/tarPlugin.vim
 25: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/plugin/tohtml.vim
 26: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
 27: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/plugin/zipPlugin.vim
 28: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/ftplugin/python.vim
 29: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/indent/python.vim
 30: /usr/local/Cellar/macvim/8.0-146_1/MacVim.app/Contents/Resources/vim/runtime/syntax/python.vim
还尝试将其添加到
.vimrc

if &term =~ '256color'
  " disable Background Color Erase (BCE) so that color schemes
  " render properly when inside 256-color tmux and GNU screen.
  set t_ut=
endif
set background=dark
highlight Normal ctermbg=NONE
highlight nonText ctermbg=NONE
编辑(2): 下面是同一主题的截图,它是如何在屏幕上呈现的

  • terminal.app

  • hyper.app

  • 和Mac vim gui(正确):
  • 给定一个适当的
    $TERM
    ,Vim将始终正常工作,因此黑客攻击如下:

    set t_Co=256
    
    它们通常是无用的

    如果您打算使用256color就绪配色方案,
    $TERM
    应以
    256color
    结尾:

    xterm-256color   prefered for general usage
    screen-256color  if you use Vim in screen or tmux
    tmux-256color    if you use Vim in tmux and your terminal emulator supports it
    
  • 如果可能,
    $TERM
    不应设置在shell级别,而应设置在终端仿真器级别。在Hyper.app中,这是在
    ~/.Hyper.js
    env
    键中完成的:

    env: {TERM: 'xterm-256color'},
    
    同样的逻辑也适用于tmux和screen,它们的作用类似于终端模拟器

  • 那个片段是一个无用的黑客:

    if &term =~ '256color'
      " disable Background Color Erase (BCE) so that color schemes
      " render properly when inside 256-color tmux and GNU screen.
      set t_ut=
    endif
    
  • 下面的屏幕截图显示了Hyper.app中的256color ready Vim colorscheme在不同场景下的完美工作,没有任何漏洞:

    下图:Vim,在Hyper.app中

    下图:Vim,在tmux中,在Hyper.app中

    我没有费心去改变Hyper.app的主题,因为我不打算在回答这个问题后再使用它,但你希望能得到这个想法

  • 从那里,您可以:

    • ~/.hyper.js
      中查找配色方案的背景色,并将其应用于终端仿真器的主题,以使难看的填充更令人满意

    • 完全删除Vim的背景,以便将终端仿真器与以下内容一起使用:

      function! MyHighlights() abort
          highlight Normal      ctermbg=NONE
          highlight NonText     ctermbg=NONE
          highlight EndOfBuffer ctermbg=NONE
      endfunction
      
      augroup MyColors
          autocmd!
          autocmd ColorScheme * call MyHighlights()
      augroup END
      colorscheme foobar
      
  • 试用

    我还发布了两个解决方案,用于背景色在Hyper中不起作用

    这是我发布的第二个可能适用于您的解决方案:

    • 在.vimrc中,将vim背景设置为透明:
    • 将终端的背景更改为所需的背景色

    我尝试了您的解决方案,从
    .bashrc
    .zshrc
    中删除了
    $TERM
    定义,在hyper中使用了
    env
    ,但我仍然无法正确获得它。我编辑了我的问题,并添加了与问题中提到的主题相同的屏幕截图,以及如何在terminal.app、hyper.app和mac vim gui上呈现,除了gui之外,一切似乎都遵循自己的方式。如果你能帮我调试这种行为的原因,那就太好了。那个垃圾不支持256色终端模拟器。它是为GUI Vim、8/16color终端仿真器和支持新的花式“真彩色”功能的终端仿真器而设计的。路径A:为自己准备一个合适的256色配色方案。路径B:使终端颜色与配色方案匹配。路径C:如果Hyper.app支持“真彩色”功能,请将Vim设置为与
    :help'termguicolors'
    一起使用。只是为了确保我继续并再次尝试了该功能,并且得到了类似的结果。GUI工作正常,但背景+语法突出显示颜色仍然很暗,混乱不堪,这是他们自己的意愿。即使在terminal.app和hyper.app上都设置了
    set background=light
    ,只是为了在同一页面上,你说的“那混蛋”是指我的主题对吗?尝试了一系列终端主题,其中一些给了我这个错误,比如在处理/Users/...vim/plucked/iosvkem/colors/iosvkem.vim:line 11:[iosvkem]没有足够的颜色。