Vim Solarized on OS X Terminal.app Incorrect Colors [duplicate]
Asked Answered
R

1

11

Possible Duplicate:
Why don’t most vim color schemes look as nice as the screenshot when I use them?

I'm trying to transfer my vim configuration to be using it only from the terminal. Currently i'm using gVim and everything works fine.

But in terminal.app, the color scheme is off.. I'm using the Solarized 256 theme for terminal.app and the solarized theme in vim.

This is what they look like:

gVim left, Terminal.app Right

I had to set g:solarized_termtrans = 1 to get ti background to even show the right color.

Renaldo answered 30/12, 2012 at 18:51 Comment(7)
See why don't most vim color schemes look as nice as the screenshotFulfil
Setting t_Co=256 didn't change anything :(Renaldo
But did you also change your $TERM environment? to see its current state, echo $TERM. If it isn't something like xterm-256color you will need to set it as such. (in the Terminal.app prefs, I suppose)Fulfil
Yes, I made sure it was xterm-256color (it already was) and even tried TERM=xterm-256color vimRenaldo
Can you post a screenshot or link to screenshot which is big enough to discern what's showing then?Fulfil
i.sstatic.net/HIKdT.png (left being gvim)Renaldo
This is not a duplicate. This is a different issue.Passional
T
9

I had this problem myself once.

However the following statement fixed everything, here's how I control Terminal support in my .vimrc file: https://github.com/Greduan/dotfiles/blob/8b48b0d788c0fed6fc14720bbe3ae9def31af947/vim/vimrc.vim#L550-L556

if !has('gui_running')
    " Compatibility for Terminal
    let g:solarized_termtrans=1

    " Make Solarized use 16 colors for Terminal support
    let g:solarized_termcolors=16
endif

Which basically fixes it for Terminal if you're using Terminal. Try using :let g:solarized_termcolors = 16.

Pseudo code:

  • If the user isn't using a GUI:
    • Then set the termtrans equal to one.
    • And tell Vim to only use 16 colors, or 256 if your Terminal supports it (don't know one that does).
  • Endif

EDIT 1:

If you are sure you're using a 256 color terminal then you can also just leave this alone and it'll work perfectly. Like so: https://github.com/Greduan/dotfiles/blob/6dac113d8281b0201399831bf62a2ea520d28154/vim/vimrc.vim#L551-L561

if !has('gui_running')
    " Compatibility for Terminal
    let g:solarized_termtrans=1

    if (&t_Co >= 256 || $TERM == 'xterm-256color')
        " Do nothing, it handles itself.
    else
        " Make Solarized use 16 colors for Terminal support
        let g:solarized_termcolors=16
    endif
endif

What this does is check if you have a Terminal. If it does set termtrans, then check if your Terminal has 256 colors, if it does leave it alone, if it doesn't then set Solarized to use 16 colors. This works out much better.

Teferi answered 30/12, 2012 at 20:45 Comment(6)
Im not really sure how, but this has fixed it. I KNOW I tried the 16 colors lolRenaldo
Turns out, I didn't try the 16 colors setting after switching my Terminal.app to the custom solarized theme. Works now! If anyone has this problem, try using this Terminal.app themeRenaldo
Glad that solved the problem for you jackyyll! :)Teferi
Only problem with this solution is that then many colors are lost from what I've noticed, or there's less unique colors. I'm still trying to find out a reason why it doesn't work and how to fix it. I'll report back later if I find out.Teferi
OK, found out that the best way to solve this if your Terminal has 256 colors is to simply not do anything, leave it alone.Teferi
let g:solarized_termcolors=256 helped me.Leishaleishmania

© 2022 - 2024 — McMap. All rights reserved.