A better syntax highlighting color scheme for Ruby code on V

On Sun, Sep 03, 2006 at 09:27:05AM +0900, M. Edward (Ed) Borasky wrote:
[…]
} Curiously enough, when Red Hat dropped Red Hat 10 in favor of Fedora
and
} some expensive “enterprise” distros, I switched to Debian. I really
} liked Debian, although it took them a long time to come out with
“sarge”
} as a stable product. And I really liked being able to bring up
“dselect”
} and be a kid in a candy store. Darn near anything I could use or
wanted
} to learn how to use was in there.

I don’t think there will ever be a good, coherent message about what
Debian
“stable” means. From my perspective, stable is something to run on an
internet-facing server that doesn’t need to be behind a hardware
firewall.
I use a mix of testing and unstable on all of my Debian machines.

} The fly in Debian’s ointment was their disdain for Java. A lot of the
} things I wanted to run were written in Java. So I went looking around
} for another distro and settled on Gentoo, about six months after
} switching from Red Hat to Debian.

Whatever floats your boat. I’ve had good success with Java on Debian,
even
using IBM’s Java on PowerPC. It was a pain for a while, I’ll grant you,
but
it’s gotten better. Eventually someone scratched that itch and created
java-package, which takes the various downloadable Java installs and
turns
them into .deb files.

} I don’t personally code in Java, nor do I hack on the open-source
tools
} I use that are written in Java. But in certain application areas
} (workstation, not server, in my case) the really good packages are
} written in Java.

Many are, true. As I said, it took a while but Debian folks realized
that,
too. I’ve installed, for example, Azureus with apt-get. It just kind of
works now, like all the other packages always did.

Oh, and just to dig at Gentoo for kicks (and all in good fun), have you
seen http://www.funroll-loops.org/?

–Greg

On 9/2/06, James B. [email protected] wrote:

Alder G. wrote:

How do I get a nice color scheme that would do a better job of
visually differentiating the various Ruby-related syntactical
elements?

See if this helps:

http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-java.html

Thanks, that link is very nice. Not sure yet if it helps with my
stated specific problem - all the Ruby syntax elements that are
undifferentiated in my current scheme may also be so in the schemes on
that website.

But thanks anyway :slight_smile:

On 9/3/06, John G. [email protected] wrote:

I assume you’re using gvim (which is GTK-based, rather than plain vim).

As James B. recommended: http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/

“zenburn” is very nice if you like dark backgrounds.

I tried several, but finally settled on denim, which I’ve been using
happily for the last two years.

martin

Robin S. wrote:

That makes the comments a bright blue, something like cyan. Try it!

Yeah … that is better. Still, when I edit a Ruby file, the comments
are in “cyan”, the “def” keyword is in a “pale blue” that almost looks
like cyan, and the method name after the “def” is the same color as the
comments, but brighter (boldface?). It’s as though the coloring was
designed not so much to flag certain syntactic elements as it was to
provide contrasting tokens.

Hi Alder,

On Sat, 02 Sep 2006 18:34:37 +0900, Alder G. wrote:

global variables, block parameters, predefined constants and variables
How do I get a nice color scheme that would do a better job of
visually differentiating the various Ruby-related syntactical
elements?

Long post follows…

Not too sure how this will appear but here we go:

stick this in your .vimrc

map hl :echo “hi<” .
synIDattr(synID(line("."),col("."),1),“name”) . ‘> trans<’ .
synIDattr(synID(line("."),col("."),0),“name”) . “> lo<” .
synIDattr(synIDtrans(synID(line("."),col("."),1)),“name”) . “>”

(thats all on one line)

Now type ‘\hl’ without the quotes on any (key)word in a ruby file.
assuming ‘’ is mapped as - (the default)

You should see something like:
hi trans lo
echoed on the command line.

What this is saying is that particular keyword is linked to the
highlighting for ‘rubyDefine’ and you can tweak that any way you want
using (for eg):
hi rubyDefine cterm=none ctermfg=#f5f5f5 ctermbg=white
(replace ‘cterm’ with ‘gui’ if you’re using gvim as I do)

If you don’t specifically define it as above it defaults to PreProc
which
is how I have it.

Here’s a list of other ruby specific keywords you can modify:

hi link rubyBoolean Boolean
hi link rubyComment Comment
hi link rubyString Constant
hi link rubyStringDelimiter Constant
" hi rubyASCIICode
" hi rubyAccess
" hi rubyAttribute
" hi rubyBeginEnd gui= guifg=
guibg=
hi rubyBlock gui=none guifg=#33664D
guibg=white
" hi rubyBlockArgument
" hi rubyBlockParameter
hi rubyClass gui=none guifg=grey30
guibg=white
hi rubyClassVariable gui=none guifg=#556B2F
guibg=white
hi rubyConstant gui=none guifg=#DC143C
guibg=white
hi rubyControl gui=none guifg=#4169E1
guibg=white
hi rubyCurlyBlock gui=none guifg=#008B8B
guibg=white
" hi rubyData gui= guifg=
guibg=
" hi rubyDataDirective gui= guifg=
guibg=
" hi rubyDefine gui= guifg=
guibg=
" hi rubyDelimEscape
" hi rubyDoBlock
" hi rubyDocumentation gui= guifg=
guibg=
" hi rubyError
" hi rubyEscape
" hi rubyEval
" hi rubyException gui= guifg=
guibg=
hi rubyExprSubst gui=none guifg=#FF4500
guibg=white
" hi rubyFloat
hi rubyFunction gui=none guifg=grey50
guibg=white
" hi rubyGlobalVariable gui= guifg=
guibg=
" hi rubyHeredocStart
" hi rubyIdentifier gui= guifg=
guibg=
" hi rubyInclude gui= guifg=
guibg=
" hi rubyInstanceVariable gui= guifg=
guibg=
" hi rubyInteger
" hi rubyInterpolation
hi rubyIterator gui=none guifg=#ff7f50
guibg=white
hi rubyKeyword gui=none guifg=#008B8B
guibg=white
" hi rubyKeywordAsMethod
" hi rubyLocalVariableOrMethod
" hi rubyModule
" hi rubyNestedAngleBrackets
" hi rubyNestedCurlyBraces
" hi rubyNestedParentheses
" hi rubyNestedSquareBrackets
" hi rubyNoDoBlock
" hi rubyNoInterpolation
" hi rubyNumber gui= guifg=
guibg=
" hi rubyOperator
" hi rubyOptDoBlock
" hi rubyOptDoLine
" hi rubyPredefinedConstant gui= guifg=
guibg=
" hi rubyPredefinedIdentifier gui= guifg=
guibg=
" hi rubyPredefinedVariable gui= guifg=
guibg=
" hi rubyPseudoVariable
" hi rubySharpBang gui= guifg=
guibg=
" hi rubySpaceError
hi rubySymbol gui=none guifg=#CD853F
guibg=white
" hi rubyTodo gui= guifg=
guibg=

I got this by running the highlighttest script whilst a ruby script was
loaded. Then s///g until only ruby specific keywords remained.

The above is a file I save as ruby_cols.vim in .vim/ftplugin/
As you can see I don’t tweak it too much, but I will one day :wink:

You can do this for any filetype. Just remember to name it
_xxx.vim. egs ruby_cols.vim, ruby_abs.vim, php_cols.vim etc.
(ruby_abs.vim is ruby specific abbreviations)

cheers,

On Mon, 04 Sep 2006 11:29:41 +0900, M. Edward (Ed) Borasky wrote:

Mark W. wrote:

stick this in your .vimrc

Oh, yeah? Try and make me!

:slight_smile:

It does sound a bit harsh. Sorry about that :wink:

Mark W. wrote:

stick this in your .vimrc

Oh, yeah? Try and make me!

:slight_smile:

On 9/3/06, Alder G. [email protected] wrote:

Thanks, that link is very nice. Not sure yet if it helps with my
stated specific problem - all the Ruby syntax elements that are
undifferentiated in my current scheme may also be so in the schemes on
that website.

I’ve been using the “desert” color scheme (I may be biases as my
brother wrote it, but I like it nonetheless) for many years. This
color scheme has been included in the install for many years, and at
least recently, a decent ruby.vim syntax file is also included in the
install. So now on a new machine I can just install vim and set
colorscheme=desert in my vimrc and be good to go. Since the new
ruby.vim syntax file has been included, I’ve never had a problem with
undifferentiated tokens. The colorscheme does suffer from the
dark-blue comments on black background when you’re in CLI vim, but the
rest of it works out fine.

Mostly, my point was that since desert has good differentiation of
tokens using the default ruby.vim syntax file, most of the others
mentioned on that page should probably do pretty well also. If they’re
not, there might be something weird (or old) about your vim setup.

FWIW,

Jacob F.

Alder G. wrote:

How do I get a nice color scheme that would do a better job of
visually differentiating the various Ruby-related syntactical
elements?

The wife was very enthused about the new http://www.ruby-lang.org
design and particularly the syntax highlighting here so it fell
upon me to create something as close to that as possible. I did
have to change the syntax file a bit to get better granularity
of elements. Anyway:

Syntax file:
http://journal.kittensoft.org/assets/2006/9/15/ruby.vim

Colours:
http://journal.kittensoft.org/assets/2006/9/15/rubylang.vim

It looks pretty nice. I am test-driving it myself.

Thanks Jacob, and anyone else who contributed to this thread.

After trying dozens of Vim color schemes, both popular and obscure, I
eventually picked zeburn[1], with oceandeep[2] a close second.

These two color schemes had the highest level of syntactical
differentiation out of the box (there are several other schemes on
that level, but I couldn’t find any higher level). Still some place
for Ruby-specific improvements by customization, e.g. define a
different color for instance vs. class variables, which Vim actually
recognizes as two different syntactical elements: rubyInstanceVariable
vs rubyClassVarible. Vanilla zenburn and oceandeep link both highlight
groups to rubyIdentifier, thus failing to visually differentiate them.

I’ve spent quite a few hours coding in zenburn in the last few days,
and it is indeed easy on the eyes for long coding sessions. I’ve yet
to test oceandeep extensively.

-Alder

[1] Zenburn - Low contrast colour scheme for low light conditions : vim online
[2] oceandeep - dark colorscheme, pleasant, mainly blue and blueish-green : vim online