vim配色方案不呈现背景色

时间:2018-07-18 01:45:57

标签: vim terminal macvim hyper

尝试过的解决方案:如{s}中指出的,将export TERM=xterm-256color添加到.bashrc.zshrc,还添加set t_Co=256.vimrc。其他问题的解决方案。

是的,我正在使用支持gui和终端here的配色方案。

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

来自其他Stack Overflow问题的相当奇怪的事情是: 将此添加到我的.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

将我的vim背景更改为深灰色(我不知道它来自哪里),但是将其删除则会将其更改回我的终端背景颜色。

我将接受任何解决方案(因为我受够了,让它正常工作),以便我可以使用mac vim guiColor Picker.app获取十六进制颜色,并可以将其强制设置为每当我决定更改主题时,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

set background=dark
highlight Normal ctermbg=NONE
highlight nonText ctermbg=NONE

编辑(2):

以下是相同主题的屏幕截图以及如何在

上呈现
  • terminal.appenter image description here

  • hyper.app

enter image description here

  • 和Mac vim gui(正确): enter image description here

2 个答案:

答案 0 :(得分:1)

  1. 给定正确的$TERM,Vim会始终正常运行,因此hack如下:

    set t_Co=256
    

    通常没用。

    如果您打算使用支持256色的颜色方案,则$TERM应该以{{1​​}}结尾:

    256color
  2. 如果可能的话,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 不应在外壳程序级别上设置,而应在终端仿真程序级别上设置。在Hyper.app中,这是通过$TERM的{​​{1}}键完成的:

    env

    tmux和屏幕使用相同的逻辑,就像终端模拟器一样。

  3. 该代码段是无用的hack:

    ~/.hyper.js
  4. 以下是屏幕快照,显示了在不同情况下Hyper.app中完美运行256色的Vim色彩设计,没有任何漏洞

    以下:Hyper.app中的Vim。

    Vim

    以下:tmux中Hyper.app中的Vim。

    Vim in tmux

    我没有费心更改Hyper.app的主题,因为在此答案之后我不打算使用它,但是希望您能理解。

  5. 从那里,您可以:

    • 查找您的colorcheme的背景色,并将其应用于env: {TERM: 'xterm-256color'}, 中终端仿真器的主题,以使丑陋的填充更加可口,

    • 完全删除Vim的背景,以便将终端仿真器用于以下目的:

      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
      

答案 1 :(得分:0)

尝试使用https://github.com/chriskempson/base16-vim

我还发布了两种解决方法来解决背景色在Hyper here中不起作用

这是我发布的第二个解决方法可能对您有用:

  • 在您的.vimrc中,将vim背景设置为透明:
git add -p
  • 将终端的背景更改为所需的背景颜色
相关问题