Tuesday, March 23, 2010

Re: Jump to Javascript function prototype

Hi Michael,

Thanks for the gentle nudge in the right direction. I did read
tagsrch.txt help file but must have skimmed it too fast and missed the
vital 'tags' option.

For the benefit of the list, I ended up getting it working as follows:
1. create my own javascript.vim syntax file (copy the original one)
2. append the file with the line :set tags+=$VIM/vimfiles/mytags

It now references my tags file (yay!). The only problem now is that
some tags can't be resolved. For example, I have an object A and
object B. Each object is of a different "class". Each object has a
"doSomething()" method available, but the parameters are different
depending on whether I'm looking at object A or B - how to identify
which doSomething() tag to lookup??

In this regard, I'm starting to think that Vim is not well-prepared
for the explosion of object-orientated, loosely typed, scripting
languages. The omnicompletion and tags functions would need to
implement an interpreter for each language in order to figure out what
the correct completion/tag lookup is meant to be... sounds tricky!

Cheers,
Gareth

On Mar 22, 7:37 pm, Michael Henry <v...@drmikehenry.com> wrote:
> On 03/22/2010 12:35 AM, Gareth Oakes wrote:
>
> > 1. CTRL-W }
>
> > Seems exactly like what I want, but requires me to build a tags file
> > and include it in every folder where I have .js files.
>
> > My function prototypes are global, is there some way to have a
> > "global" tags file in a central location? eg. under $VIM?
>
> Have you looked at the 'tags' option?
>
>   :help 'tags'
>
> With the right path setup in 'tags', you can use a single
> ``tags`` file in the root directory of your JavaScript projects,
> if that's what you want.
>
> In my C projects, I usually keep Vim's current working
> directory at the top of the project rather than changing into
> the directory immediately containing the file I'm editing, so I
> keep a ``tags`` file at the top of the tree of files for my
> current project, but you could add an absolute path to 'tags' if
> you like, and generate the tags from your "prototype" files.
>
> I also run the ``ctags`` tool as follows:
>
>   ctags                               \
>       --recurse                       \
>       --c-kinds=+px                   \
>       --c++-kinds=+px                 \
>       --fields=+iaS                   \
>       --extra=+q
>
> In particular, the ``--recurse`` flag tells ``ctags`` to descend
> into subdirectories to extract tags from your source code.  I
> don't know what JavaScript-specific switches you'll want to use,
> but the basic idea should get you going.
>
> > 2. [I
>
> > Jumps to matches for the current keyword, looking in all included
> > files. Unfortunately, Javascript has no #include equivalent.
>
> > Can I manually forces files into the list that the include commands
> > search?
>
> With a recursively generated ``tags`` file as described above,
> you may find you are content with tags-related commands such as:
>
>   CTRL-]     " Jump to the tag under cursor (like :tag).
>   g]         " Use :tselect for tag under cursor.
>
> See more at:
>
>   :help tagsrch.txt
>
> Michael Henry

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

No comments: