Vim plugin that displays tags in a window, ordered by scope
Go to file
David Hegland cd74f18d10
Add JumpToNearbyTag functionality (#780)
* Add JumpToNearbyTag functionality

Closes #779

Updated functions:

`s:GetNearbyTag()` - Allow for a direction parameter to be passed into
the routine. This will allow for a forward or backward search. It will
default to a backward search line the current behavior if the
`a:direction` parameter is not used.

`s:JumpToTag()` - Allow for an optional parameter to be passed in to
specify the tag instead of using the tag under the cursor on the current
line. This also allows this routine to be executed from the file window
instead of the tagbar window. Assume `autoclose=0` if passing in the tag.

Add new functions:

`s:JumpToNearbyTag()` - This routine will do a forward or backward search
for the nearst tag using the `GetNearbyTag()` with the new direction
field, then call the `JumpToTag()` with the tag we found.

`tagbar#jumpToNextTag()` - New public facing wrapper routine around the
`JumpToNearbyTag()` routine. Optionally take in `a:lnum` and
`a:search_method` to be used in other routines. If `a:lnum` is not
present, then the line number will search from the next or previous line
depending on the `a:direction` value.

TODO:
- [ ] Still need to write up the documentation for this.
- [ ] Possibly look at providing default keymap. Currently this can be
  done using a custom definition in `.vimrc`.

* Add documentation and fix lazy scroll

Added documentation for this feature
Corrected the lazy scroll behavior when the next/prev tag is visible
Use the existing `w:autoclose` if set, else default to 0.

* Fix argument ordering

Correct the argument ordering and numbering for the jumpToNearbyTag()
routine.
Add documentation example for the 'nearest' search-method.
Rename jumpToNextTag() to jumpToNearbyTag() to be more inline with the
other routines.

* remove debug

* Fix current line processing

In the event there is a tag on the immediately previous/next line, then
the GetNearbyTag will return that tag even if the scoped-stl
search-method is set.

* Cleanup optional argument initialization

* Update tagbar#jumpToNearbyTag() - remove lnum and add flags parameter

Changes to the tagbar#jumpToNearbyTag() routine to allow more
flexibility. Removing the optional lnum parameter as this likely will
not be needed and could actually cause confusion in its use. Add a flags
field so different options can be set such as the 's':'scroll_offset'
option.
2021-08-04 09:26:06 -05:00
.github Include Paypal link to tip @raven42 in sponsor config 2021-05-21 18:47:56 +03:00
autoload Add JumpToNearbyTag functionality (#780) 2021-08-04 09:26:06 -05:00
doc Add JumpToNearbyTag functionality (#780) 2021-08-04 09:26:06 -05:00
plugin Add JumpToNearbyTag functionality (#780) 2021-08-04 09:26:06 -05:00
syntax Accommodate packagers with tagged release; using HEAD still recommended 2021-01-21 07:54:15 +03:00
.gitattributes Move tests into separate repository 2013-04-24 15:57:22 +12:00
.gitignore Update .gitignore 2020-11-03 11:12:13 +03:00
.info Add simple info file 2011-11-25 22:48:02 +13:00
.vintrc.yaml Setup GitHub Actions to lint vimscript 2019-10-22 17:23:55 +03:00
LICENSE Update URLs to reflect repository migration (Closes #651) 2020-09-13 10:22:09 +03:00
README.md Callout @raven42 as active maintainer 2021-05-21 18:47:19 +03:00

Tagbar: a class outline viewer for Vim

Vint
Check

What Tagbar is

Tagbar is a Vim plugin that provides an easy way to browse the tags of the
current file and get an overview of its structure. It does this by creating a
sidebar that displays the ctags-generated tags of the current file, ordered by
their scope. This means that for example methods in C++ are displayed under
the class they are defined in.

What Tagbar is not

Tagbar is not a general-purpose tool for managing tags files. It only
creates the tags it needs on-the-fly in-memory without creating any files.
tags file management is provided by other plugins, like for example
easytags.

Dependencies

  • Vim >= 7.3.1058
    or any version of NeoVim.

  • A ctags implementation: We highly recommend any version of Universal
    Ctags
    . It is a maintained fork of Exuberant Ctags with
    many bugfixes, support for many more formats, and proper Unicode support.

    Exuberant Ctags 5.5 or higher works to some
    degree but will be deprecated eventually.

    Some additional formats can also be handled by other providers such as
    jsctags or
    phpctags.

Installation

Extract the archive or clone the repository into a directory in your
'runtimepath', or use a plugin manager of your choice like
pathogen. Don't forget to run
:helptags if your plugin manager doesn't do it for you so you can access the
documentation with :help tagbar.

If the ctags executable is not installed in one of the directories in your
$PATH environment variable you have to set the g:tagbar_ctags_bin
variable, see the documentation for more info.

Quickstart

Put something like the following into your ~/.vimrc:

nmap <F8> :TagbarToggle<CR>

If you do this the F8 key will toggle the Tagbar window. You can of course use
any shortcut you want. For more flexible ways to open and close the window
(and the rest of the functionality) see the documentation using :help tagbar.

Support for additional filetypes

For filetypes that are not supported by Exuberant Ctags check out the
wiki
to see whether other projects
offer support for them and how to use them. Please add any other
projects/configurations that you find or create yourself so that others can
benefit from them, too.

Note: If the file structure display is wrong

If you notice that there are some errors in the way your file's structure is
displayed in Tagbar, please make sure that the bug is actually in Tagbar
before you report an issue. Since Tagbar uses
exuberant-ctags and compatible programs to do
the actual file parsing, it is likely that the bug is actually in the program
responsible for that filetype instead.

There is an example in :h tagbar-issues about how to run ctags manually so
you can determine where the bug actually is. If the bug is actually in ctags,
please report it on their website instead, as there is nothing I can do about
it in Tagbar. Thank you!

You can also have a look at ctags bugs that have previously been filed
against Tagbar
.

Screenshots

screenshot1
screenshot2

License

Tagbar is distributed under the terms of the Vim license, see the included LICENSE file.

Contributors

Tagbar was originally written by Jan Larres.
It is actively maintained by Caleb Maclennan and David Hegland.
At least 75 others have contributed features and bug fixes over the years.
Please document issues or submit pull requests on Github.