chriskempson / tomorrow-theme

Tomorrow Theme
Other
13.73k stars 3.17k forks source link

Fixed color issues when viewing diffs in Vim #258

Closed squarefrog closed 10 years ago

squarefrog commented 10 years ago

The default settings for diffs look fine when using Tomorrow. But if you use another theme like Tomorrow-Night, then it looks hideous:

default

This pull request fixes the look in each of the alternative schemes.

Tomorrow-Night

tomorrow-night


Tomorrow-Night-Blue

blue


Tomorrow-Night-Bright

bright


Tomorrow-Night-Eighties

eighties


The default Tomorrow theme is left as is, because it looks fine with the default settings

tomorrow

chriskempson commented 10 years ago

Great :smile:

jcassee commented 10 years ago

With these changes my diffs look worse when viewing git changes with the Tomorrow-Night-Bright theme. See the difference between the two screenshots.

Commit 86486d4: commit 86486d4

Commit eaa5f94: commit eaa5f94

squarefrog commented 10 years ago

I had that bug when viewing running git commit without passing a message. I patched it in a standalone version I run https://github.com/squarefrog/tomorrow-night.vim/commit/11875fcfd9efb31e45602bb0bdab6c578dd9306e But haven't had chance to make the changes here yet. Take a look and submit a PR!

squarefrog commented 10 years ago

Those two lines in that commit I referenced will just work in any of the tomorrow themes so should be a fine fix for you.

jcassee commented 10 years ago

Thanks, Paul. So this change should be applied to all themes I guess?

squarefrog commented 10 years ago

Yes - it can safely be added across all themes as it uses the built in red/green colors. My original patch concerns looking at the diff between two files either by launching with vimdiff or diff this

There are actually a whole bunch of git attributes in vim but I couldn't figure out how most would be useful.

jcassee commented 10 years ago

Alright, I'll whip something up!

squarefrog commented 10 years ago

Awesome! If you get stuck or something looks wierd give me a shout.

jcassee commented 10 years ago

@squarefrog Now that I have your attention :-), I noticed that when editing a Git commit message, the theme does not give the first 50 characters of the first line special significance (i.e. bold) like some other themes do. Do you how to do that?

squarefrog commented 10 years ago

Do you have any examples? It sounds reasonably trivial, if a bit opinionated.

jcassee commented 10 years ago

I believe the canonical source of the "rule" is a post by Tim Pope from 2008, but the format is pretty popular -- at least where I come.

See for example this commit message in the darkburn theme:

selectie_001

squarefrog commented 10 years ago

My immediate guess is that the git plugin possibly supports this and has a property available. I can look tomorrow as there is a vim function that says what hl group matches under the cursor.

jcassee commented 10 years ago

Good tip, I think I got it:

syn match   gitcommitFirstLine  "\%^[^#].*"  nextgroup=gitcommitBlank skipnl
syn match   gitcommitSummary    "^.\{0,50\}" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell
syn match   gitcommitOverflow   ".*" contained contains=@Spell
syn match   gitcommitBlank      "^[^#].*" contained contains=@Spell

And so this line will make the first 50 characters of the commit summary bold:

hi gitcommitSummary cterm=bold
squarefrog commented 10 years ago

Yeah that'd do it! So I don't know if that last line would work in these themes, or if you may need

call <SID>X("gitcommitSummary", "", "", "bold")

I think just making it bold, and not changing the colours is a nice touch as it's subtle but noticeable.

jcassee commented 10 years ago

Create pull request #262. Thanks again @squarefrog. Have a good evening!