|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
More syntax highlighting funOkay, I've followed up on several changes I mentioned earlier. Most
obvious is the change of rubyConstant to Type and rubySymbol to Constant. I think the first looks great and I strongly advocate keeping it. The second is more debatable but after trying it for a few hours, I like it enough to tenatively add it. I'm not trying to force anything here but since nobody raised any objections, I figured I'd be bold. More important than a few cosmetic changes is the overhaul I gave to method, module, and class definitions. Try all of the following with the new syntax file: def bar def bar def foo.bar def @foo.bar def Foo.bar def Foo::bar def self.bar I think this will be win-win for everyone. We can also turn off the rubyFunction highlghting by default. I'm not sure whether that's a better choice so I left it on for now to demonstrate what's possible. I also did a lot of clean-up, so let me know if you find anything that breaks. Things like if/unless are in the Conditional group and while/until in the Loop group. Oh, and I had to resolve a conflict between Doug Kearns' and my ways of highlighting interpolated variables. Is there any reason for keeping around config options like ruby_no_identifiers? I don't see what let ruby_no_identifiers = 1 offers over hi link rubyIdentifer NONE Both work fine in a vimrc. Maybe this is a holdover from the 5.x days? Cheers, Tim Pope _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Thu, Feb 22, 2007 at 11:32:36AM -0600, Tim Pope wrote:
<snip> > More important than a few cosmetic changes is the overhaul I gave to > method, module, and class definitions. Thanks! > Try all of the following with the new syntax file: > > def bar > > def > bar > > def foo.bar > > def @foo.bar > > def Foo.bar > > def Foo::bar > > def self.bar > > I think this will be win-win for everyone. We can also turn off the > rubyFunction highlghting by default. I'm not sure whether that's a > better choice so I left it on for now to demonstrate what's possible. > > I also did a lot of clean-up, so let me know if you find anything that > breaks. >From a quick inspection I noticed that the following are not being highlighted properly: def foo ; end # whitespace after method name def foo(x); end # with parameter list (also empty list) def Foo::bar;end # specified with :: def []; end # all redefinable operator methods Otherwise it looks great. > Things like if/unless are in the Conditional group and > while/until in the Loop group. Shouldn't that be the Repeat group? > Oh, and I had to resolve a conflict > between Doug Kearns' and my ways of highlighting interpolated > variables. > > Is there any reason for keeping around config options like > ruby_no_identifiers? I don't see what > > let ruby_no_identifiers = 1 > > offers over > > hi link rubyIdentifer NONE > > Both work fine in a vimrc. Maybe this is a holdover from the 5.x > days? It's really just the "Vim Way" of doing things - at least as I understand it. Generally the configuration options are there to allow people to customize the highlighting without any need to understand syntax files. I think you'd be surprised how many people use Vim with absolutely no understanding of these details. ;-) Regards, Doug _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Fri, 23 Feb 2007, Doug Kearns wrote:
> It's really just the "Vim Way" of doing things - at least as I > understand it. Generally the configuration options are there to allow > people to customize the highlighting without any need to understand > syntax files. I think you'd be surprised how many people use Vim with > absolutely no understanding of these details. ;-) Well, it *is* rather frightening when you prise the lid off. I still don't fully unerstand these things, even though I have meddled with -- er, I mean sent patches for this stuff before. Think of it as the Facade Pattern :-) > > Regards, > Doug Hugh _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Fri, Feb 23, 2007 at 07:56:03PM +1100, Doug Kearns wrote:
> On Thu, Feb 22, 2007 at 11:32:36AM -0600, Tim Pope wrote: > > More important than a few cosmetic changes is the overhaul I gave to > > method, module, and class definitions. > From a quick inspection I noticed that the following are not being > highlighted properly: > > def foo ; end # whitespace after method name > def foo(x); end # with parameter list (also empty list) > def Foo::bar;end # specified with :: Fixed all 3. Turns out the difference between .\@<! and \.\@<! is quite large :). > def []; end # all redefinable operator methods You may not have intended it, but this is by far the best case I have heard for highlighting method names: indicating whether they are valid, including the appropriate operators. I've added matching for all operators that can be overloaded; the list is hopefully both exhaustive and exclusive. Building on this, I added highlighting for aliases as well. The way I did this is a little crude and may need some refining, so let me know if there are problems. > > > Things like if/unless are in the Conditional group and > > while/until in the Loop group. > > Shouldn't that be the Repeat group? Doh, shows how often I use these primitive constructs. I see you fixed the hi link; I renamed the group as well. > It's really just the "Vim Way" of doing things - at least as I > understand it. Generally the configuration options are there to allow > people to customize the highlighting without any need to understand > syntax files. I think you'd be surprised how many people use Vim with > absolutely no understanding of these details. ;-) True to an extent, but some of this strikes me as "giving a man a fish". Actually, I think in my example, the "hi link" is *easier* to understand. You don't have to know how "let" differs from "set", and why it sometimes but not always needs a "g:" in there to work. Plus, having such config variables in place sends the message, "the changes you can make are limited to these config variables". I'm updating the documentation in the repository to recommend my alternative instead ruby_no_identifiers. There is precedent for this in other syntax file documentation, including ft-c-syntax. If nobody reverts this change, I may do this for other options as well, but the highlighting code needs to be restructured first in order to enable this. I'm leaving ruby_no_identifiers in syntax/ruby.vim itself for backwards compatibility. Cheers, Tim _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Fri, Feb 23, 2007 at 12:10:53PM -0600, Tim Pope wrote:
> On Fri, Feb 23, 2007 at 07:56:03PM +1100, Doug Kearns wrote: > > On Thu, Feb 22, 2007 at 11:32:36AM -0600, Tim Pope wrote: > > > More important than a few cosmetic changes is the overhaul I gave to > > > method, module, and class definitions. > > From a quick inspection I noticed that the following are not being > > highlighted properly: > > > > def foo ; end # whitespace after method name > > def foo(x); end # with parameter list (also empty list) > > def Foo::bar;end # specified with :: > > Fixed all 3. Turns out the difference between .\@<! and \.\@<! is > quite large :). Thanks. > > def []; end # all redefinable operator methods > > You may not have intended it, but this is by far the best case I have > heard for highlighting method names: indicating whether they are > valid, including the appropriate operators. I guess... It's probably the best to highlight them by default. It certainly seems to be what all the other kids are doing. > I've added matching for > all operators that can be overloaded; the list is hopefully both > exhaustive and exclusive. You missed == and & which I've added. <snip> > > It's really just the "Vim Way" of doing things - at least as I > > understand it. Generally the configuration options are there to allow > > people to customize the highlighting without any need to understand > > syntax files. I think you'd be surprised how many people use Vim with > > absolutely no understanding of these details. ;-) > > True to an extent, but some of this strikes me as "giving a man a > fish". Actually, I think in my example, the "hi link" is *easier* to > understand. You don't have to know how "let" differs from "set", and > why it sometimes but not always needs a "g:" in there to work. Plus, > having such config variables in place sends the message, "the changes > you can make are limited to these config variables". That's a good point. <snip> Regards, Doug _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Fri, Feb 23, 2007 at 12:10:53PM -0600, Tim Pope wrote:
> On Fri, Feb 23, 2007 at 07:56:03PM +1100, Doug Kearns wrote: > > On Thu, Feb 22, 2007 at 11:32:36AM -0600, Tim Pope wrote: > > > More important than a few cosmetic changes is the overhaul I gave to > > > method, module, and class definitions. > > From a quick inspection I noticed that the following are not being > > highlighted properly: > > > > def foo ; end # whitespace after method name > > def foo(x); end # with parameter list (also empty list) > > def Foo::bar;end # specified with :: > > Fixed all 3. Turns out the difference between .\@<! and \.\@<! is > quite large :). The following are incorrect at the moment: def end?; end def end=; end def end!; end Here's a couple of quick fixes: Index: syntax/ruby.vim =================================================================== RCS file: /var/cvs/vim-ruby/vim-ruby/syntax/ruby.vim,v retrieving revision 1.104 diff -u -b -r1.104 ruby.vim --- syntax/ruby.vim 24 Feb 2007 04:02:50 -0000 1.104 +++ syntax/ruby.vim 24 Feb 2007 10:08:08 -0000 @@ -163,7 +163,7 @@ syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl - syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\<end\>" contains=TOP fold + syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\<end\>[?!=]\@!" contains=TOP fold syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=TOP fold syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=TOP fold Index: syntax/ruby.vim =================================================================== RCS file: /var/cvs/vim-ruby/vim-ruby/syntax/ruby.vim,v retrieving revision 1.104 diff -u -b -r1.104 ruby.vim --- syntax/ruby.vim 24 Feb 2007 04:02:50 -0000 1.104 +++ syntax/ruby.vim 24 Feb 2007 10:09:34 -0000 @@ -163,7 +163,7 @@ syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl - syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\<end\>" contains=TOP fold + syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\<end\>" contains=TOP fold skip="\<end[?!=]" syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=TOP fold syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=TOP fold <snip> Regards, Doug _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Fri, Feb 23, 2007 at 12:10:53PM -0600, Tim Pope wrote:
<snip> > I'm updating the documentation in the repository to recommend my > alternative instead ruby_no_identifiers. There is precedent for this > in other syntax file documentation, including ft-c-syntax. If nobody > reverts this change, I may do this for other options as well, but the > highlighting code needs to be restructured first in order to enable > this. I'm leaving ruby_no_identifiers in syntax/ruby.vim itself for > backwards compatibility. It might also be an idea to, at least, rename that awkwardly named ruby_no_expensive variable. Any ideas? Regards, Doug _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Fri, Feb 23, 2007 at 12:10:53PM -0600, Tim Pope wrote:
<snip> > Building on this, I added highlighting for > aliases as well. The way I did this is a little crude and may need > some refining, so let me know if there are problems. It can't be disabled by setting ruby_no_special_methods anymore. Is that intentional? <snip> Regards, Doug _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Sat, Feb 24, 2007 at 11:22:48PM +1100, Doug Kearns wrote:
> On Fri, Feb 23, 2007 at 12:10:53PM -0600, Tim Pope wrote: > > Building on this, I added highlighting for > > aliases as well. The way I did this is a little crude and may need > > some refining, so let me know if there are problems. > > It can't be disabled by setting ruby_no_special_methods anymore. Is > that intentional? Well, I hadn't really considered that, but alias is not a method. It's syntax, just like def, class, and module. Cheers, Tim _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Sat, Feb 24, 2007 at 09:14:52PM +1100, Doug Kearns wrote:
> The following are incorrect at the moment: > > def end?; end > def end=; end > def end!; end I missed these because apparently Debian patches the ftplugin to set iskeyword+=!,? . The merits of this are debatable so I'm not copying that, but I will be copying the keywordprg=ri they also patched in. To further the original point, even the following is valid: def end; end Yes, end really can be a method name. So I'll be changing the pattern to something like "\%(\<def\s\+\)\@<!\<end\>". This still doesn't fix the indenting, but that's a much tougher nut to crack. Cheers, Tim _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Sat, Feb 24, 2007 at 07:29:03PM -0600, Tim Pope wrote:
> On Sat, Feb 24, 2007 at 11:22:48PM +1100, Doug Kearns wrote: > > On Fri, Feb 23, 2007 at 12:10:53PM -0600, Tim Pope wrote: > > > Building on this, I added highlighting for > > > aliases as well. The way I did this is a little crude and may need > > > some refining, so let me know if there are problems. > > > > It can't be disabled by setting ruby_no_special_methods anymore. Is > > that intentional? > > Well, I hadn't really considered that, but alias is not a method. > It's syntax, just like def, class, and module. Which is a good reason to exclude from that group. ;-) Regards, Doug _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Sat, Feb 24, 2007 at 07:47:22PM -0600, Tim Pope wrote:
> On Sat, Feb 24, 2007 at 09:14:52PM +1100, Doug Kearns wrote: > > The following are incorrect at the moment: > > > > def end?; end > > def end=; end > > def end!; end > > I missed these because apparently Debian patches the ftplugin to set > iskeyword+=!,? . The merits of this are debatable so I'm not copying > that, but I will be copying the keywordprg=ri they also patched in. Aren't they supposed to send these changes 'upstream'? I wasn't aware they were patching these files...it might explain a few bug reports. *sigh* <snip> Regards, Doug _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Sun, Feb 25, 2007 at 07:27:59PM +1100, Doug Kearns wrote:
> On Sat, Feb 24, 2007 at 07:29:03PM -0600, Tim Pope wrote: > > On Sat, Feb 24, 2007 at 11:22:48PM +1100, Doug Kearns wrote: > > > On Fri, Feb 23, 2007 at 12:10:53PM -0600, Tim Pope wrote: > > > > Building on this, I added highlighting for > > > > aliases as well. The way I did this is a little crude and may need > > > > some refining, so let me know if there are problems. > > > > > > It can't be disabled by setting ruby_no_special_methods anymore. Is > > > that intentional? > > > > Well, I hadn't really considered that, but alias is not a method. > > It's syntax, just like def, class, and module. > > Which is a good reason to exclude from that group. ;-) And even luckier it was never a part of it anyway. It's such a worry... Regards, Doug _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Fri, Feb 23, 2007 at 12:10:53PM -0600, Tim Pope wrote:
<snip> > Building on this, I added highlighting for > aliases as well. The way I did this is a little crude and may need > some refining, so let me know if there are problems. It seems it's not currently highlighting symbol or global variable args. <snip> Regards, Doug _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Sun, Feb 25, 2007 at 08:23:25PM +1100, Doug Kearns wrote:
> On Fri, Feb 23, 2007 at 12:10:53PM -0600, Tim Pope wrote: > > <snip> > > > Building on this, I added highlighting for > > aliases as well. The way I did this is a little crude and may need > > some refining, so let me know if there are problems. > > It seems it's not currently highlighting symbol or global variable > args. ...or capitalised method names. Regards, Doug _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Sun, Feb 25, 2007 at 07:30:15PM +1100, Doug Kearns wrote:
> On Sat, Feb 24, 2007 at 07:47:22PM -0600, Tim Pope wrote: > > On Sat, Feb 24, 2007 at 09:14:52PM +1100, Doug Kearns wrote: > > > The following are incorrect at the moment: > > > > > > def end?; end > > > def end=; end > > > def end!; end > > > > I missed these because apparently Debian patches the ftplugin to set > > iskeyword+=!,? . The merits of this are debatable so I'm not copying > > that, but I will be copying the keywordprg=ri they also patched in. > > Aren't they supposed to send these changes 'upstream'? I wasn't aware > they were patching these files...it might explain a few bug reports. > *sigh* Yes, generally they should be. I know a rather active Debian package maintainer for Vim; I'll see if I can get some answers out of him. Cheers, Tim _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Sun, Feb 25, 2007 at 08:38:54PM +1100, Doug Kearns wrote:
> On Sun, Feb 25, 2007 at 08:23:25PM +1100, Doug Kearns wrote: > > It seems it's not currently highlighting symbol or global variable > > args. Fixed. I forgot the former because it's so strange, and I never knew about the latter. > ...or capitalised method names. I fixed these in aliases and in method declarations as well. Cheers, Tim _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Sat, Feb 24, 2007 at 07:47:22PM -0600, Tim Pope wrote:
<snip> > To further the original point, even the following is valid: > > def end; end > > Yes, end really can be a method name. So I'll be changing the pattern > to something like "\%(\<def\s\+\)\@<!\<end\>". This still doesn't fix > the indenting, but that's a much tougher nut to crack. I changed this to use \_s to allow for: def end end ...since we're being thorough. ;-) Regards, Doug _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Thu, Feb 22, 2007 at 11:32:36AM -0600, Tim Pope wrote:
<snip> > I also did a lot of clean-up, so let me know if you find anything that > breaks. self isn't being highlighted in these two examples. class <<self end class<<self end <snip> Regards, Doug _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
|
|
Re: More syntax highlighting funOn Tue, Feb 27, 2007 at 12:09:12AM +1100, Doug Kearns wrote:
<snip> > self isn't being highlighted in these two examples. > > class <<self > end > > class<<self > end I've fixed this with the following. Let me know if I'm overlooking something. Regards, Doug Index: syntax/ruby.vim =================================================================== RCS file: /var/cvs/vim-ruby/vim-ruby/syntax/ruby.vim,v retrieving revision 1.111 diff -u -b -r1.111 ruby.vim --- syntax/ruby.vim 26 Feb 2007 09:51:06 -0000 1.111 +++ syntax/ruby.vim 26 Feb 2007 13:33:26 -0000 @@ -155,8 +155,8 @@ syn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable nextgroup=rubyAliasDeclaration2 skipwhite syn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable syn match rubyMethodDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable -syn match rubyClassDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant -syn match rubyModuleDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant +syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant +syn match rubyModuleDeclaration "[^[:space:];#]\+" contained contains=rubyConstant syn match rubyFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:].:?!=]\@!" contained containedin=rubyMethodDeclaration syn match rubyFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2 syn match rubyFunction "\%([[:space:].]\|^\)\@<=\%(\[\]=\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|==\|=\~\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration _______________________________________________ vim-ruby-devel mailing list vim-ruby-devel@... http://rubyforge.org/mailman/listinfo/vim-ruby-devel |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |