Hi Alder,

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

> I've been migrating to Vim recently. It has impressive Ruby/Rails
> support: indentation, intellisense for Ruby and Rails objects, a lot
> of shortcuts for fast editing of Rails projects... you can even script
> Vim in Ruby!
> 
> Vim also has good syntax-highlighting support. Unfortunately, the
> color scheme applied through the syntax highlighting sucks. It lumps
> together too many elements:
> 
> Methods, symbols, constants, class variables, instance variables,
> global variables, block parameters, predefined constants and variables
> --
> 
> All those are colored blue. Which completely defeats the purpose of
> syntax-highlighting, to help you visually differentiate between the
> various syntactical elements of the code.
> 
> Apparently, all the above (and several others)  *are* differentiated
> by the Vim Ruby syntax parser. However, the default color scheme
> colors them all the same. So the problem is with the color scheme.
> 
> 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 <leader>hl  :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>

(thats all on one line)

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

You should see something like:
	hi<rubyDefine> trans<rubyDefine> lo<PreProc>
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 ;-)


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



cheers,

-- 
Mark