altercation / solarized

precision color scheme for multiple applications (terminal, vim, etc.) with both dark/light modes
http://ethanschoonover.com/solarized
MIT License
15.79k stars 3.52k forks source link

Vim Solarized Looks Horrible in Terminal.app in Lion #146

Open sorin-ionescu opened 13 years ago

sorin-ionescu commented 13 years ago

Solarized

Even though I use the Solarized theme in Terminal, Solarized isn't working in the normal mode. Terminal.app identifies itself properly as xterm-256color and tput colors reports 256, as does t_Co. g:solarized_termcolors reports 16.

I have to use the 256 degraded mode.

if colors_name == 'solarized'
  if has('gui_macvim')
    set transparency=0
  endif

  if !has('gui_running') && $TERM_PROGRAM == 'Apple_Terminal'
    let g:solarized_termcolors = &t_Co
    let g:solarized_termtrans = 1
    colorscheme solarized
  endif

  call togglebg#map("<F2>")
endif

Solarized Degraded

vguerci commented 13 years ago

Seen that pull request? > https://github.com/altercation/solarized/pull/83

that gives that (iTerm2 on left with standard solarized, Terminal Lion with that pull on right): iTerm2 vs Terminal

Not perfect, but a lot better... (btw I prefer its stronger contrast...)

off-topic, any reason to prefer Terminal to iTerm2? iTerm2 is imho so much better... (I love using only one HotKey fullscreen window (à la visor) with panes and tabs)

sorin-ionescu commented 13 years ago

@vguerci, yes, this is a problem with the Terminal colours. Solarized has Lion Terminal themes (Solarized Dark xterm-256color.terminal and Solarized Light xterm-256color.terminal), but they are broken. I'll fix them and make my own pull request.

Yes, in some respects, such as having mouse support, iTerm2 is better. But for most people Terminal is good enough. All I wanted from Terminal was 256 colours support, which it now has.

vguerci commented 13 years ago

Are you sure? I see that repository last update in May, before lion. I think the osx terminal theme there is only ok with SL + some SIMBL extension. I had the same ugly colors than you have before trying that pull request.

sorin-ionescu commented 13 years ago

That pull request is not accurate. I'm creating my own themes for both iTerm and Terminal. Then I'll close this issue and submit a pull request.

darthdeus commented 12 years ago

@vguerci I had the same issue today and actually ended up tweaking the terminal colors by hand, mostly just making them darker. The result isn't perfect, but it's certainly better than what it does by default

Terminal.app VIM

jdelStrother commented 12 years ago

Don't know how much this will help, but I have a MacPro that I installed Terminal colors from https://github.com/altercation/solarized/pull/83 on, and it worked fine. On my Macbook Air, the same colors give me the ugly grey background in vim.

Both are running 10.7.2, and have identical .vimrc & .zshrcs. I'm really struggling to spot what the difference is...

sorin-ionescu commented 12 years ago

Though, I have not tested #83, I have also fixed the colours in both Terminal and iTerm. I shall open my own pull request.

However, fixing the terminal colours is not enough. You also have to add logic to your .vimrc for Solarized to work properly.

" Color Scheme ----------------------------------------------------------- {{{

" Set the color scheme.
try
    set background=dark
    colorscheme solarized
catch /E185:/
    colorscheme default
endtry

" }}}

" Solarized -------------------------------------------------------------- {{{

 if exists('g:colors_name') && g:colors_name == 'solarized'
    " Text is unreadable with background transparency.
    if has('gui_macvim')
        set transparency=0
    endif

    " Highlighted text is unreadable in Terminal.app because it
    " does not support setting of the cursor foreground color.
    if !has('gui_running') && $TERM_PROGRAM == 'Apple_Terminal'
        let g:solarized_termcolors = &t_Co
        let g:solarized_termtrans = 1
        colorscheme solarized
    endif

    call togglebg#map("<F2>")
endif

" }}}

Unreadable Highlight in Terminal.app

Unreadable Solarized

Readable Highlight in Terminal.app

Readable Solarized

Unfortunately, all colours are altered, and it looks worse, but it is usable.

sorin-ionescu commented 12 years ago

Another option to retain the original colours and make visual selection readable is to set the colour in vimrc.

" Solarized -------------------------------------------------------------- {{{

if exists('g:colors_name') && g:colors_name == 'solarized'
    " Text is unreadable with background transparency.
    if has('gui_macvim')
        set transparency=0
    endif

    " Highlighted text is unreadable in Terminal.app because it
    " does not support setting of the cursor foreground color.
    if !has('gui_running') && $TERM_PROGRAM == 'Apple_Terminal'
        if &background == 'dark'
            hi Visual term=reverse cterm=reverse ctermfg=10 ctermbg=7
        endif
    endif
    call togglebg#map("<F2>")
endif

" }}}

However, if you toggle the background, it will revert back to the unreadable visual selection colour. So, the toggle background code also has to be patched.

" Solarized -------------------------------------------------------------- {{{

if exists('g:colors_name') && g:colors_name == 'solarized'
    " Text is unreadable with background transparency.
    if has('gui_macvim')
        set transparency=0
    endif

    " Highlighted text is unreadable in Terminal.app because it
    " does not support setting of the cursor foreground color.
    if !has('gui_running') && $TERM_PROGRAM == 'Apple_Terminal'
         if &background == 'dark'
            hi Visual term=reverse cterm=reverse ctermfg=10 ctermbg=7
        endif

        function! PatchedTogBG()
            let &background = ( &background == "dark"? "light" : "dark" )
            if exists("g:colors_name")
                exe "colorscheme " . g:colors_name
                if g:colors_name == "solarized" && &background == 'dark'
                    hi Visual term=reverse cterm=reverse ctermfg=10 ctermbg=7
                endif
            endif
        endfunction
        command! ToggleBG :call PatchedTogBG()
        silent! nnoremap <F2> :ToggleBG<CR>
        silent! inoremap <F2> :ToggleBG<CR>
        silent! vnoremap <F2> :ToggleBG<CR>
    endif
    call togglebg#map("<F2>")
endif

" }}}
gpakosz commented 12 years ago

well I'm doing let g:solarized_termtrans=1 in my .vimrc.local as instructed there http://ethanschoonover.com/solarized/vim-colors-solarized:

Note that on Mac OS X Terminal.app, solarized_termtrans is set to 1 by default as this is almost always the best option. The only exception to this is if the working terminfo file supports 256 colors (xterm–256color).

moonglum commented 12 years ago

What is the status of this ticket?

I tried @sorin-ionescu's version, the result for Vim looks as follows (Terminal.app on the left, iTerm.app on the right):

Solarized Problem

The colors are wrong in Terminal.app, the highlight is broken :( What is the best way to approach this? I would try to fix it myself.

What is really odd: If I try a colortest like this Perl Script, the colors are equal. Why does it work in a script like this?

sorin-ionescu commented 12 years ago

You cannot fix the Vim highlight in Terminal.app directly since Terminal.app does not support setting the highlight foreground colour. However, there is a workaround. Check my vimrc in my dot files.

sorin-ionescu commented 12 years ago

Also, though the colours in iTerm and Terminal are indeed equal, they look different because iTerm uses a different colour space. I don't know which is the correct one, but it is a know issue in the iTerm bug tracker.

moonglum commented 12 years ago

Ok, thanks :) I used the snippet from above and this version of the color schema. Now it works :)

prayagupa commented 8 years ago

setting following properties in .vimrc worked for me (mac terminal),

let g:solarized_termcolors= 16
let g:solarized_termtrans = 16

let g:solarized_bold = 1
let g:solarized_underline = 1 
let g:solarized_italic = 1
let g:solarized_contrast = "high"
let g:solarized_visibility= "high"

My dotfiles -> https://github.com/prayagupd/dotfiles-mac/blob/master/.vimrc#L12

Rainymood commented 8 years ago

Not sure whether I'm doing this correctly but prayagupd's solution worked for me! I've spent a lot of time in macvim but I was missing my tmux bindings. Now my Vim looks pretty again! Thans a lot!

ashah03 commented 6 years ago

let g:solarized_termtrans = 1 resolved it for me; the background becomes the same as whatever terminal you are using.