Method definition highlighting

View: New views
9 Messages — Rating Filter:   Alert me  

Method definition highlighting

by Doug Kearns :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

One of the reasons I'd temporarily forgotten that the current CVS wasn't
highlighting method names specially in method definitions is because
I've never liked it and have a local customization to prevent it.

I much prefer the "self" in:

def self.bar: end

and the "Foo" in:

def Foo::bar; end

to be highlighted normally as rubyPseudoVariable, rubyConstant and
rubyLocalVariableOrMethod respectively rather than all of them being
highlighted as part of the artificial rubyFunction.

Does anyone else have any thoughts on this?

Regards,
Doug
_______________________________________________
vim-ruby-devel mailing list
vim-ruby-devel@...
http://rubyforge.org/mailman/listinfo/vim-ruby-devel

Re: Method definition highlighting

by Nikolai Weibull-11 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2/20/07, Doug Kearns <dougkearns@...> wrote:

> One of the reasons I'd temporarily forgotten that the current CVS wasn't
> highlighting method names specially in method definitions is because
> I've never liked it and have a local customization to prevent it.
>
> I much prefer the "self" in:
>
> def self.bar: end
>
> and the "Foo" in:
>
> def Foo::bar; end
>
> to be highlighted normally as rubyPseudoVariable, rubyConstant and
> rubyLocalVariableOrMethod respectively rather than all of them being
> highlighted as part of the artificial rubyFunction.
>
> Does anyone else have any thoughts on this?

Can't remember if I have this disable as well, but highlighting self
does make sense, I think.

  nikolai
_______________________________________________
vim-ruby-devel mailing list
vim-ruby-devel@...
http://rubyforge.org/mailman/listinfo/vim-ruby-devel

Re: Method definition highlighting

by Tim Pope-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Feb 20, 2007 at 02:37:14PM +0100, Nikolai Weibull wrote:
> Can't remember if I have this disable as well, but highlighting self
> does make sense, I think.

As you're no doubt aware, this is easy enough to accomplish by adding
a contains=rubyPseudoVariable to the appropriate line.

Cheers,

Tim
_______________________________________________
vim-ruby-devel mailing list
vim-ruby-devel@...
http://rubyforge.org/mailman/listinfo/vim-ruby-devel

Re: Method definition highlighting

by Tim Pope-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Feb 20, 2007 at 10:02:36PM +1100, Doug Kearns wrote:
> One of the reasons I'd temporarily forgotten that the current CVS wasn't
> highlighting method names specially in method definitions is because
> I've never liked it and have a local customization to prevent it.

Well, I can't say I ever particularly cared for it either, although it
is a common practice in Vim syntax highlighting.  Recently, I was
working on cloning "vibrant ink," a TextMate theme popular with Rails
users.  I added the rubyRegexp group in pursuit of this goal, which is
when I discovered the method name highlighting problem.  The theme in
question definitely looks better with such method name highlighting in
place.  So I'd at least like to keep it as a possibility.

> I much prefer the "self" in:
>
> def self.bar: end
>
> and the "Foo" in:
>
> def Foo::bar; end
>
> to be highlighted normally as rubyPseudoVariable, rubyConstant and
> rubyLocalVariableOrMethod respectively rather than all of them being
> highlighted as part of the artificial rubyFunction.

Certainly a possibility.  To get the original effect, you'd have to
highlight all rubyLocalVariableOrMethod objects as Identifier, at
which point it'd probably be easier to highlight all the things that
aren't identifiers, as the screen is going to be saturated with it.

The amount of Identifier highlighting has always bothered me with the
current syntax file, actually.  I've tried disabling various things to
reduce it,  I'm happy to hack around it, but if while we're discussing
the subject, I figure I may as well throw my two cents into the pot.

One possible alternative is to move symbols into the Constant group
with numbers and strings.  This is more logical, in a way, and my
understanding is this is how TextMate works.  I do like having symbols
highlighted differently from strings, but from a theoretical
perspective it might make more sense to change String highlighting in
the color scheme instead.  Of course, this is not the default, so that
should be taken into account as well.

One group that doesn't get much play is Type.  Might it make more
sense to highlight constants (the capitalized kind) using this group.
This makes sense in cases where constants are classes.  In the cases
where they're not, well, keep in mind method declarations aren't
exactly PreProc either.  Making this change would basically allow us
to drop all the fanciness for module/class declarations as well.  The
colons would be different, but I don't think that's a bad thing.

Going on a real tangent now, it just occured to me a different use for
the Type group.  I find the variations of highlighting of "end" to be
extrordinarily useful.  Perhaps it would make sense to use the Type
group as a third color?  This strikes me as potentially very useful
for keeping things matched up.  You could also drop the module/class
fanciness in this case, as you'd want the class/module name to be
distinct from the introducing keyword.  I'm committing changes that
make this possible, but I am leaving the default highlighting for it
as PreProc until I have spent some time playing with it.

Cheers,

Tim
_______________________________________________
vim-ruby-devel mailing list
vim-ruby-devel@...
http://rubyforge.org/mailman/listinfo/vim-ruby-devel

Re: Method definition highlighting

by Doug Kearns :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Feb 20, 2007 at 09:47:49AM -0600, Tim Pope wrote:

<snip>
 
> The amount of Identifier highlighting has always bothered me with the
> current syntax file, actually.  I've tried disabling various things to
> reduce it,  I'm happy to hack around it, but if while we're discussing
> the subject, I figure I may as well throw my two cents into the pot.

I take it you've noticed ruby_no_identifiers?
 
<snip>

Regards,
Doug
_______________________________________________
vim-ruby-devel mailing list
vim-ruby-devel@...
http://rubyforge.org/mailman/listinfo/vim-ruby-devel

Re: Method definition highlighting

by Tim Pope-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Feb 21, 2007 at 05:29:53PM +1100, Doug Kearns wrote:

> On Tue, Feb 20, 2007 at 09:47:49AM -0600, Tim Pope wrote:
>
> <snip>
>  
> > The amount of Identifier highlighting has always bothered me with the
> > current syntax file, actually.  I've tried disabling various things to
> > reduce it,  I'm happy to hack around it, but if while we're discussing
> > the subject, I figure I may as well throw my two cents into the pot.
>
> I take it you've noticed ruby_no_identifiers?

Sure.  It's rather all or nothing though.  Basically the only thing
left is method declaration highlighting then (and talk is of
eliminating that too).  Nonetheless, I can hack up just about anything
with enough :highlight rules, I'm just after the most sensible
possible defaults.  If I could only define sensible.
_______________________________________________
vim-ruby-devel mailing list
vim-ruby-devel@...
http://rubyforge.org/mailman/listinfo/vim-ruby-devel

Re: Method definition highlighting

by Andrew Stewart-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 20 Feb 2007, at 15:47, Tim Pope wrote:
> Recently, I was
> working on cloning "vibrant ink," a TextMate theme popular with Rails
> users.

Any chance you could post your vibrant ink somewhere?

(Or should that be vimbrant ink?)

Thanks and regards,
Andy Stewart

_______________________________________________
vim-ruby-devel mailing list
vim-ruby-devel@...
http://rubyforge.org/mailman/listinfo/vim-ruby-devel

Re: Method definition highlighting

by Tim Pope-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Feb 21, 2007 at 11:19:44AM +0000, Andrew Stewart wrote:
> Any chance you could post your vibrant ink somewhere?
>
> (Or should that be vimbrant ink?)

I'm calling it vividchalk :).  I'm attaching what is still a work in
process.  I've decided not to go for an exact clone, after seeing how
the HTML highlighting in TextMate is rather ugly, in my opinion.
Feedback welcome; I'm still deciding how to do a lot of the Vim
specific stuff like the statusline and completion menu.

Cheers,

Tim

" Vim color scheme
" Name:         vividchalk.vim
" Maintainer:   Tim Pope <vim@...>
" Last Change:  19 Feb 2007

if has("gui_running")
    set background=dark
endif
hi clear
if exists("syntax_on")
   syntax reset
endif

let colors_name = "vividchalk"

" First two functions adapted from inkpot.vim

" map a urxvt cube number to an xterm-256 cube number
fun! s:M(a)
    return strpart("0135", a:a, 1) + 0
endfun

" map a urxvt colour to an xterm-256 colour
fun! s:X(a)
    if &t_Co == 88
        return a:a
    else
        if a:a == 8
            return 237
        elseif a:a < 16
            return a:a
        elseif a:a > 79
            return 232 + (3 * (a:a - 80))
        else
            let l:b = a:a - 16
            let l:x = l:b % 4
            let l:y = (l:b / 4) % 4
            let l:z = (l:b / 16)
            return 16 + s:M(l:x) + (6 * s:M(l:y)) + (36 * s:M(l:z))
        endif
    endif
endfun

function! s:choose(good,mediocre)
    if &t_Co != 88 && &t_Co != 256
        return a:mediocre
    else
        return s:X(a:good)
    endif
endfunction

function! s:hifg(group,guifg,ctermfg,backup)
    let ctermfg = s:choose(a:ctermfg,a:backup)
    exe "highlight ".a:group." guifg=".a:guifg." ctermfg=".ctermfg
endfunction

function! s:hibg(group,guibg,ctermbg,backup)
    let ctermbg = s:choose(a:ctermbg,a:backup)
    exe "highlight ".a:group." guibg=".a:guibg." ctermbg=".ctermbg
endfunction

hi link railsMethod         PreProc
hi link rubyDefine          Keyword
hi link rubySymbol          Constant
hi link rubyAccess          rubyMethod
hi link rubyAttribute       rubyMethod
hi link rubyEval            rubyMethod
hi link rubyException       rubyMethod
hi link rubyInclude         rubyMethod
hi link rubyStringDelimiter rubyString
hi link rubyRegexp          Regexp
hi link rubyRegexpDelimiter rubyRegexp
"hi link rubyConstant        Variable
"hi link rubyGlobalVariable  Variable
"hi link rubyClassVariable   Variable
"hi link rubyInstanceVariable Variable
hi link javascriptRegexpString  Regexp
hi link javascriptNumber        Number
hi link javascriptNull          Constant

if &background == "light" || has("gui_running")
    hi Normal guifg=White guibg=Black ctermfg=White ctermbg=Black
else
    hi Normal guifg=White guibg=Black ctermfg=White ctermbg=NONE
endif
highlight StatusLine   guifg=Black guibg=White gui=bold ctermfg=Black ctermbg=White cterm=bold
highlight StatusLineNC guifg=Black guibg=Grey gui=italic ctermfg=Black ctermbg=Grey cterm=none
highlight Cursor     guifg=Black guibg=White ctermfg=Black ctermbg=White
highlight CursorLine guibg=#333333 guifg=NONE
highlight CursorColumn guibg=#333333 guifg=NONE
highlight NonText    guifg=#404040 ctermfg=8
highlight SpecialKey guifg=#404040 ctermfg=8
highlight Directory  none
high link Directory  Identifier
highlight ErrorMsg   guibg=Red ctermbg=DarkRed guifg=NONE ctermfg=NONE
highlight Search     guibg=#101000 ctermbg=Black guifg=NONE ctermfg=NONE gui=italic cterm=underline
highlight MoreMsg    guifg=#00AA00 ctermfg=Green
highlight LineNr     guifg=#DDEEFF ctermfg=White
call s:hibg("LineNr"        ,"#222222",80,"DarkBlue")
highlight Question   none
high link Question   MoreMsg
highlight Title      guifg=Magenta ctermfg=Magenta
hi VisualNOS gui=none cterm=none
call s:hibg("Visual"        ,"#888888",83,"LightBlue")
call s:hibg("VisualNOS"     ,"#555555",81,"DarkBlue")
highlight WarningMsg    guifg=Red ctermfg=Red
highlight Folded        guibg=#1100aa ctermbg=DarkBlue
call s:hibg("Folded"        ,"#110077",17,"DarkBlue")
call s:hifg("Folded"        ,"#aaddee",63,"LightCyan")
highlight FoldColumn    none
high link FoldColumn    Folded
highlight Pmenu         guifg=White ctermfg=White gui=bold cterm=bold
highlight PmenuSel      guifg=White ctermfg=White gui=bold cterm=bold
call s:hibg("Pmenu"     ,"#000099",18,"Blue")
call s:hibg("PmenuSel"  ,"#5555ff",39,"DarkCyan")
highlight PmenuSbar     guibg=Grey ctermbg=Grey
highlight PmenuThumb    guibg=White ctermbg=White
highlight TabLine       gui=underline cterm=underline
call s:hifg("TabLine"   ,"#bbbbbb",85,"LightGrey")
call s:hibg("TabLine"   ,"#333333",80,"DarkGrey")
highlight TabLineSel    guifg=White guibg=Black ctermfg=White ctermbg=Black
highlight TabLineFill   gui=underline cterm=underline
call s:hifg("TabLineFill"   ,"#bbbbbb",85,"LightGrey")
call s:hibg("TabLineFill"   ,"#808080",83,"Grey")

hi Type gui=none
hi Statement gui=none
"highlight PreProc       guifg=#EDF8F9
call s:hifg("Comment"       ,"#9933CC",51,"DarkMagenta") " 92
call s:hifg("Constant"      ,"#339999",21,"DarkCyan") " 30
call s:hifg("rubyNumber"    ,"#CCFF33",60,"Yellow") " 190
call s:hifg("String"        ,"#66FF00",44,"LightGreen") " 82
call s:hifg("Identifier"    ,"#FFCC00",72,"Yellow") " 220
call s:hifg("Statement"     ,"#FF6600",68,"LightRed") " 202
call s:hifg("PreProc"       ,"#AAFFFF",47,"LightCyan") " 213
call s:hifg("Type"          ,"#999966",57,"Brown") " 101
call s:hifg("Special"       ,"#AAAAAA", 7,"Grey") " 7
call s:hifg("Regexp"        ,"#44B4CC",21,"DarkCyan") " 74
call s:hifg("rubyMethod"    ,"#DDE93D",77,"Yellow") " 191
"highlight railsMethod   guifg=#EE1122 ctermfg=1

_______________________________________________
vim-ruby-devel mailing list
vim-ruby-devel@...
http://rubyforge.org/mailman/listinfo/vim-ruby-devel

Re: Method definition highlighting

by Andrew Stewart-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 21 Feb 2007, at 15:08, Tim Pope wrote:

> On Wed, Feb 21, 2007 at 11:19:44AM +0000, Andrew Stewart wrote:
>> Any chance you could post your vibrant ink somewhere?
>>
>> (Or should that be vimbrant ink?)
>
> I'm calling it vividchalk :).  I'm attaching what is still a work in
> process.  I've decided not to go for an exact clone, after seeing how
> the HTML highlighting in TextMate is rather ugly, in my opinion.
> Feedback welcome; I'm still deciding how to do a lot of the Vim
> specific stuff like the statusline and completion menu.

Nice name.

Thanks for posting vividchalk.  It looks pretty good.

The only colour I changed was the one used for visual selections.  I  
found that the grey was sufficiently light to make the text  
underneath, for most colours, hard to read.  So I darkened it and  
that helped a lot.

Regards,
Andy Stewart
_______________________________________________
vim-ruby-devel mailing list
vim-ruby-devel@...
http://rubyforge.org/mailman/listinfo/vim-ruby-devel