molokai icon indicating copy to clipboard operation
molokai copied to clipboard

Diff lines added/removed aren't green/red

Open coldhawaiian opened this issue 10 years ago • 15 comments

I'm used to viewing diffs of files where added lines are green, and removed lines are red. This is the output of git diff:

screen shot 2014-05-19 at 8 22 02 pm

When viewing such diffs with the Molokai theme, added lines are orange, while removed lines are cyan. This is the output of vim temp.diff:

screen shot 2014-05-19 at 8 23 52 pm

I've been trying to mess around with the Molokai settings to get the output to look more like what I have for git diff, especially in regard to the green/red colors of added/removed lines. In particular, I tried setting the following to Red:

  • Line 43:
    • Original

      hi DiffDelete      guifg=#960050 guibg=#1E0010
      
    • Modified

      hi DiffDelete      guifg=Red guibg=#1E0010
      
  • Line 160:
    • Original

      hi DiffDelete      ctermfg=162 ctermbg=53
      
    • Modified

      hi DiffDelete      ctermfg=Red ctermbg=53
      

Unfortunately, the changes didn't seem to do anything. Is there anything I can do to change the diff colors to be what I want?

coldhawaiian avatar May 20 '14 00:05 coldhawaiian

I have the same problem. Red / green colour are a must. Has anyone figured this out already?

Atcold avatar Sep 23 '15 14:09 Atcold

you must perform the :hi calls in a colorscheme autocmd, otherwise the colorscheme will overwrite your :hi settings. Here's what I use: https://github.com/justinmk/config/blob/master/.vimrc#L587-L607

justinmk avatar Sep 23 '15 14:09 justinmk

@justinmk, hmm... I've copied and pasted your snippet, but nothing really happens... :disappointed_relieved:

Atcold avatar Sep 23 '15 19:09 Atcold

screenshot 2015-09-23 15 25 23

How can I debug this? Can it also be incorporated into the main colour scheme, with a PR? I think it's a must!

Atcold avatar Sep 23 '15 19:09 Atcold

You need to add the snippet to your vimrc and then restart vim...

justinmk avatar Sep 23 '15 19:09 justinmk

:neutral_face: that's what I did... The right file is my ~/.vimrc, and yes, I've relaunched Vim.

screenshot 2015-09-23 15 46 03

Atcold avatar Sep 23 '15 19:09 Atcold

This is basic functionality. Ask on vi.stackexchange.com if you need help.

justinmk avatar Sep 23 '15 20:09 justinmk

@justinmk, you can try yourself. Make a ~/.vimrc with the code you pointed out and have the file ~/.vim/colors/molokai.vim. Try to see a diff and taa-daa, it does not work. Here's my ~/.vimrc, you can source it with vim -u test_vimrc.

As you suggested, I've created a question on vi@stackexchange.

Atcold avatar Sep 27 '15 10:09 Atcold

@coldhawaiian, here is the solution. Put these lines in your ~/.vimrc

colorscheme molokai
" Better gitcommit messages
hi diffAdded   ctermbg=NONE ctermfg=46  cterm=NONE guibg=NONE guifg=#00FF00 gui=NONE
hi diffRemoved ctermbg=NONE ctermfg=196 cterm=NONE guibg=NONE guifg=#FF0000 gui=NONE
hi link diffLine String
hi link diffSubname Normal

And here a before / after :grimacing:

before-after

Atcold avatar Sep 27 '15 12:09 Atcold

My mistake. Molokai should not use those colors though.

justinmk avatar Sep 27 '15 14:09 justinmk

@justinmk, to which colours are you referring? Moreover, in the solution I've suggested there is no need of the autocmd and it looks more simple. Or this won't work in some specific conditions for which you've chosen to use the autocmd?

Atcold avatar Sep 27 '15 14:09 Atcold

I'm saying molokai should not change its colors. Removing personality defeats the purpose of a colorscheme.

justinmk avatar Sep 27 '15 15:09 justinmk

@justinmk, if you use git then vim has to show git's diff colours, whatever colour scheme you have. Having the light blue and orange for removal and addition are completely deceiving, at least personally speaking. And I believe I'm not the only one of this opinion. But then, taste is subjective.

Atcold avatar Sep 27 '15 15:09 Atcold

git config color.diff.old, git config color.diff.new, may be configured to have any color. It might be an interesting feature for the Vim ftplugin for git to detect that configuration and set colors in a ft=git buffer, optionally. It's not the realm of a colorscheme though.

justinmk avatar Sep 27 '15 15:09 justinmk

Thanks, @Atcold. This was enough for me:

colo molokai
hi diffAdded ctermfg=46  cterm=NONE guifg=#2BFF2B gui=NONE
hi diffRemoved ctermfg=196 cterm=NONE guifg=#FF2B2B gui=NONE

(A little lighter than pure red/green fits better with the theme IMHO.)

liitii avatar Jul 21 '16 02:07 liitii