VIM 7.0 is known have been extended with rather advanced scripting capabilities 
such as complex data structures and object-oriented programming in embryo. So, 
now we can define methods for some object type in such a way:

let MyObjectType = {}
function! MyObjectType.method1()
        echo 'Hello world from method1!'
endf
function! MyObjectType.method2()
        echo 'Hello world from method2!'
endf

However, if one tries to open taglist for such a code one will see:
|-   variable
||         MyObjectType
|                                                        
|-   function                
||         MyObjectType
||         MyObjectType

Such a behavior most likely is far from one's expectations. Though, there is no 
any riddle here, just the latest version of exuberant ctags cannot parse new 
extensions to VIM script.

I've found an easy way to extend the latest version of ctags to make it more 
suitable for using with new VIM scripts. With this extension taglist for code 
above will look so:

|-   class
||         MyObjectType
|                            
|-   function                
||         MyObjectType.method1
||         MyObjectType.method2

Here (http://community.livejournal.com/screenshot_vim/4893.html) once more 
example.

Note that you will not be able to jump to method definitions using <C-]> 
neither with original ctags nor with patched. Though, with patched version you 
will be able to jump to method definition through taglist.

To obtain such a behavior you need to patch latest version of exuberant ctags, 
namely file vim.c

        1. Download the latest version of ctags (5.6)  here: 
http://sourceforge.net/project/showfiles.php?group_id=6556
        2. Unpack it and go to directory created: tar zxvf ctags-5.6.tar.gz; cd 
ctags-5.6
        3. Patch file vim.c with this patch:

32c32,34
<       K_VARIABLE
---
>       K_VARIABLE,
>       K_CLASS
>       
38a41
>       { TRUE,  'c', "class", "class definitions" },
105c108
<                                       } while (isalnum ((int) *cp)  ||  *cp 
== '_');
---
>                                       } while (isalnum ((int) *cp)  ||  *cp 
> == '_' || *cp == '.' || *cp == '\'' || *cp == '"' || *cp == '[' || *cp == 
> ']');
157c160
<                               } while (isalnum ((int) *cp)  ||  *cp == '_');
---
>                               } while (isalnum ((int) *cp)  ||  *cp == '_'|| 
> *cp == '.' || *cp == '\'' || *cp == '"' || *cp == '[' || *cp == ']');
159c162,176
<                               makeSimpleTag (name, VimKinds, K_VARIABLE);
---
>                               while(isspace((int) *cp))
>                                       ++cp;
>                               if(*cp == '=')
>                                       {
>                                       ++cp;
>                                       while(isspace((int) *cp))
>                                               ++cp;
>                                       if(*cp == '{' || strncmp ((const char*) 
> cp, "extend", (size_t) 6) == 0 || 
>                                               strncmp ((const char*) cp, 
> "copy", (size_t) 4) == 0 ||
>                                               strncmp ((const char*) cp, 
> "deepcopy", (size_t) 8) == 0 ||
>                                               strncmp ((const char*) cp, 
> "filter", (size_t) 6) == 0 ||
>                                               strncmp ((const char*) cp, 
> "map", (size_t) 3) == 0)
>                                               makeSimpleTag(name, VimKinds, 
> K_CLASS);
>                                       else makeSimpleTag (name, VimKinds, 
> K_VARIABLE);
>                                       }

4) Build ctags and install:
./configure
make; make install

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.10/383 - Release Date: 7/7/2006
 

Reply via email to