Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

jsfaint/gen_tags.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gen_tags.vim

This plugin was born from a little requirement of myself more than 10 years ago. After many changes then it become an usable plugin. I got many helps from the lovely people all over the world during the time. Thank you guys for all the help!

For personal reason, I already migrate to lsp for a very long time. I haven't use ctags/gtags for years. Maybe it's time to say goodbye to this plugin.

青山不改,绿水长流,我们后会有期。


Async plugin for Vim/NeoVim to ease the use of ctags/gtags.
It is used for generate and maintain tags for you with multiple platform support, tested on Windows/Linux/macOS.

gen_tags.vim will detect SCM(git, hg, svn) root and use it as the project root path. But you can also create a folder named as .root to specify a directory as the project root path.

Generate/Update ctags and gtags will run in background.

Difference between ctags and gtags

GNU global(aka gtags) is more powerful than ctags, which support definition, reference, calling, called, include, string and etc, but ctags only support definition.

As we can use GNU global why did I still support ctags in this plugin?
That's because GNU global only support 6 languages (C, C++, Yacc, Java, PHP4 and assembly) natively.
ctags can support more languages(41 showed on the website).

Actually global can support more languages with Pygments plugin parser, for more details please refer PLUGIN_HOWTO.pygments in global document.

Installation

  • dein.vim

    Add call dein#add('jsfaint/gen_tags.vim') to your vimrc
    Then launch vim/nvim and run :call dein#install()

  • vim-plug

    Add Plug 'jsfaint/gen_tags.vim' to your vimrc
     Then launch vim/nvim and run :PlugInstall

  • Traditional method

    Unzip the zip file under your .vim(*unix) or vimfiles(windows) directory.

Ctags support

Commands For Ctags

  • :GenCtags

    Generate ctags database

  • :EditExt

    Edit an extend configuration file for this project, use for add third-party library ctags database
    The extend database will be generate automatically.

    e.g.: For libpcap under e:\src\libpcap-1.3.0 add the following content to ext.conf

    e:/src/libpcap-1.3.0
  • :ClearCtags

    :ClearCtags      Remove tags files.
    :ClearCtags!     Remove all files, include the db dir

Gtags support

GTAGS support the third-party library by set an environment variable GTAGSLIBPATH
But you can take a more straightforward way to do the same thing, by create a symbol link of the library

  • Linux/macOS

    ln -s /usr/include/ .
  • Windows

    mklink /J include C:\TDM-GCC-32\include

Commands For Gtags

  • :GenGTAGS

    Generate GTAGS

  • :ClearGTAGS

    :ClearGTAGS     Remove GTAGS files
    :ClearGTAGS!    Remove all files, include the db dir

Key Mapping

ctrl+] is the default mapping support by Vim for definition

The following mapping is set for gtags when g:gen_tags#gtags_default_map is 1, which uses the cscope interface .

Ctrl+\ c    Find functions calling this function
Ctrl+\ d    Find functions called by this function
Ctrl+\ e    Find this egrep pattern
Ctrl+\ f    Find this file
Ctrl+\ g    Find this definition
Ctrl+\ i    Find files #including this file
Ctrl+\ s    Find this C symbol
Ctrl+\ t    Find this text string

Detail Usage

For more details about the usage, please refer to the help document in vim by :help gen_tags.vim


Thanks for reading :)
If you like this plugin, please star it on github!

And one more thing, bug reports and pull-requests are greatly appreciated :)