Tagbar: a Taglist-like plugin that can handle scopes like classes etc.

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Tagbar: a Taglist-like plugin that can handle scopes like classes etc.

Jan Larres
Hi all,

I have always been bothered by the fact that the Taglist plugin (while
otherwise great) doesn't display the tags sorted according to their
scope. And since I'm working a lot with C++ these days I wanted to have
something that could actually display the information in such a more
useful way.

My initial plan was to simply extend the Taglist plugin -- I assumed
that would be the easiest option since the rest of the tag handling had
already been done. But since Taglist was written before Vim 7 introduced
lists and dictionaries I found its system of dozens of variables not
exactly intuitive. Another factor was that scopes can be nested, but
implementing that without similarly nesting data structures would
probably be a nightmare. So I decided instead to write a new plugin from
scratch, using the nice data structures provided by Vim 7.

I think the plugin is pretty much done now, there are just a few things
left that would be nice to have later on but are not really essential
right now in my opinion. I'm mentioning it here now before I upload it
to vim.org so that people can have a look at it in case it still has
some bugs (a few limitations are described in the documentation). It
*does* handle things like anonymous structures, so that's not an issue.

Here is the homepage:
http://majutsushi.github.com/tagbar/

And you can get the code from here:
https://github.com/majutsushi/tagbar

I hope it will be useful to someone.

Cheers,
        Jan

--
-[ OpenPGP key ID: 00A0FD5F ]-
If a nation values anything more than freedom, it will lose its freedom; and
the irony of it is that if it is comfort or money it values more, it will
lose that, too.
                -- W. Somerset Maugham

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Tagbar: a Taglist-like plugin that can handle scopes like classes etc.

Ivan Sichmann Freitas
On Sun, Feb 20, 2011 at 12:33:09PM +1300, Jan Larres wrote:
> I hope it will be useful to someone.

At least for me, it will. Made a few tests with it, and found it more intuitive
when searching for tags than taglist. Very good work.

--
Ivan Sichmann Freitas
Linux user #509059

attachment0 (853 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Tagbar: a Taglist-like plugin that can handle scopes like classes etc.

Jeet Sukumaran
In reply to this post by Jan Larres
Excellent!! This has been one of my biggest wishes for Vim + tags for
the longest time. I just tried it, and it works beautifully. Thanks!

-- jeet

On Feb 19, 5:33 pm, Jan Larres <[hidden email]> wrote:

> Hi all,
>
> I have always been bothered by the fact that the Taglist plugin (while
> otherwise great) doesn't display the tags sorted according to their
> scope. And since I'm working a lot with C++ these days I wanted to have
> something that could actually display the information in such a more
> useful way.
>
> My initial plan was to simply extend the Taglist plugin -- I assumed
> that would be the easiest option since the rest of the tag handling had
> already been done. But since Taglist was written before Vim 7 introduced
> lists and dictionaries I found its system of dozens of variables not
> exactly intuitive. Another factor was that scopes can be nested, but
> implementing that without similarly nesting data structures would
> probably be a nightmare. So I decided instead to write a new plugin from
> scratch, using the nice data structures provided by Vim 7.
>
> I think the plugin is pretty much done now, there are just a few things
> left that would be nice to have later on but are not really essential
> right now in my opinion. I'm mentioning it here now before I upload it
> to vim.org so that people can have a look at it in case it still has
> some bugs (a few limitations are described in the documentation). It
> *does* handle things like anonymous structures, so that's not an issue.
>
> Here is the homepage:http://majutsushi.github.com/tagbar/
>
> And you can get the code from here:https://github.com/majutsushi/tagbar
>
> I hope it will be useful to someone.
>
> Cheers,
>         Jan
>
> --
> -[ OpenPGP key ID: 00A0FD5F ]-
> If a nation values anything more than freedom, it will lose its freedom; and
> the irony of it is that if it is comfort or money it values more, it will
> lose that, too.
>                 -- W. Somerset Maugham

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Tagbar: a Taglist-like plugin that can handle scopes like classes etc.

Karol Samborski
In reply to this post by Jan Larres
Thank you for such a good work! I really like it!

Karol Samborski

2011/2/20 Jan Larres <[hidden email]>:

> Hi all,
>
> I have always been bothered by the fact that the Taglist plugin (while
> otherwise great) doesn't display the tags sorted according to their
> scope. And since I'm working a lot with C++ these days I wanted to have
> something that could actually display the information in such a more
> useful way.
>
> My initial plan was to simply extend the Taglist plugin -- I assumed
> that would be the easiest option since the rest of the tag handling had
> already been done. But since Taglist was written before Vim 7 introduced
> lists and dictionaries I found its system of dozens of variables not
> exactly intuitive. Another factor was that scopes can be nested, but
> implementing that without similarly nesting data structures would
> probably be a nightmare. So I decided instead to write a new plugin from
> scratch, using the nice data structures provided by Vim 7.
>
> I think the plugin is pretty much done now, there are just a few things
> left that would be nice to have later on but are not really essential
> right now in my opinion. I'm mentioning it here now before I upload it
> to vim.org so that people can have a look at it in case it still has
> some bugs (a few limitations are described in the documentation). It
> *does* handle things like anonymous structures, so that's not an issue.
>
> Here is the homepage:
> http://majutsushi.github.com/tagbar/
>
> And you can get the code from here:
> https://github.com/majutsushi/tagbar
>
> I hope it will be useful to someone.
>
> Cheers,
>        Jan
>
> --
> -[ OpenPGP key ID: 00A0FD5F ]-
> If a nation values anything more than freedom, it will lose its freedom; and
> the irony of it is that if it is comfort or money it values more, it will
> lose that, too.
>                -- W. Somerset Maugham
>
> --
> 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
>

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Tagbar: a Taglist-like plugin that can handle scopes like classes etc.

Jan Larres
In reply to this post by Jan Larres
Thanks all! One thing I want to mention is that I'm not really familiar
with several of the languages that ctags supports, so I'm not entirely
sure if the default configuration that I've put into Tagbar is really
optimal. So if anyone knows of any improvements please tell me.

Cheers,
        Jan

--
-[ OpenPGP key ID: 00A0FD5F ]-
Nature knows no indecencies; man invents them.
                -- Mark Twain

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Tagbar: a Taglist-like plugin that can handle scopes like classes etc.

Karol Samborski
One little thing I can't see is the type of variables (I can see only
the name) - I'm writing in C++.

Karol Samborski

2011/2/22 Jan Larres <[hidden email]>:

> Thanks all! One thing I want to mention is that I'm not really familiar
> with several of the languages that ctags supports, so I'm not entirely
> sure if the default configuration that I've put into Tagbar is really
> optimal. So if anyone knows of any improvements please tell me.
>
> Cheers,
>        Jan
>
> --
> -[ OpenPGP key ID: 00A0FD5F ]-
> Nature knows no indecencies; man invents them.
>                -- Mark Twain
>
> --
> 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
>

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Tagbar: a Taglist-like plugin that can handle scopes like classes etc.

Jan Larres
Hi Karol,

Karol Samborski <[hidden email]>:
> One little thing I can't see is the type of variables (I can see only
> the name) - I'm writing in C++.

yes, that would certainly be handy. Unfortunately ctags doesn't provide
this information, so I can't do anything about it in Tagbar. Someone
would have to extend ctags first, then I could use it in Tagbar.

Cheers,
        Jan

--
-[ OpenPGP key ID: 00A0FD5F ]-
Corporation, n.: An ingenious device for obtaining individual profit without
individual responsibility.
                -- Ambrose Bierce, "The Devil's Dictionary"

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Tagbar: a Taglist-like plugin that can handle scopes like classes etc.

Karol Samborski
2011/2/22 Jan Larres <[hidden email]>:
> yes, that would certainly be handy. Unfortunately ctags doesn't provide
> this information, so I can't do anything about it in Tagbar. Someone
> would have to extend ctags first, then I could use it in Tagbar.

hmm... in my tags file generated by ctags there is for example:
BrowseDialog::lSetRecord
/home/karol.samborski/workspace/kfw/framework/include/dialog.h  /^
long lSetRecord;$/;"    m   class:BrowseDialog  access:protected

so I think it's possible...
I generated my tags file like this:
ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q
--language-force=C++ -f tags path

Another little thing is that there is no information about what
function returns.
I hope this helps.

Regards,
Karol Samborski

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Tagbar: a Taglist-like plugin that can handle scopes like classes etc.

Jan Larres
Karol Samborski <[hidden email]>:

> 2011/2/22 Jan Larres <[hidden email]>:
>> yes, that would certainly be handy. Unfortunately ctags doesn't provide
>> this information, so I can't do anything about it in Tagbar. Someone
>> would have to extend ctags first, then I could use it in Tagbar.
>
> hmm... in my tags file generated by ctags there is for example:
> BrowseDialog::lSetRecord
> /home/karol.samborski/workspace/kfw/framework/include/dialog.h  /^
> long lSetRecord;$/;"    m   class:BrowseDialog  access:protected
>
> so I think it's possible...
> I generated my tags file like this:
> ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q
> --language-force=C++ -f tags path

Unfortunately it's not that easy. The type only appears in the search
pattern of the tag, it doesn't get extracted by ctags into a usable
format. That means I would have to basically parse the line myself with
a different parser for (almost) every language, something that ctags is
already supposed to do. Since there can be many complications in a type
declaration with modifiers like 'extern', 'static' etc. in arbitrary
order, some languages having the type after the name instead of before
it, more than one declaration in a line and even macros that can
basically do what they want there is really no other way around it if
you don't want it to be wrong half of the time. Therefore it would make
a lot more sense to add this functionality to ctags directly as an
additional field, displaying this field in Tagbar would then be almost
trivial.

> Another little thing is that there is no information about what
> function returns.

Here the same thing applies as above, with the additional problem that
at least in C and C++ it's somewhat common to put the return type on a
line above the function/method name meaning that it doesn't even appear
in the search pattern. So in that case I would have no way at all to
discover it.

> I hope this helps.

I hope my answer helps with understanding the problems :). I would love
to be able to display this information, but without the help of ctags
it's not really feasible.

Cheers,
        Jan

--
-[ OpenPGP key ID: 00A0FD5F ]-
I will permit no man to narrow and degrade my soul by making me hate him.
                -- Booker T. Washington

--
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