Giter Site home page Giter Site logo

gitter-badger / gen_tags.vim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jsfaint/gen_tags.vim

0.0 0.0 0.0 107 KB

Async plugin for vim and neovim to ease the use of ctags/gtags

Home Page: https://vim.sourceforge.io/scripts/script.php?script_id=5499

License: MIT License

Vim Script 86.74% Python 13.26%

gen_tags.vim's Introduction

gen_tags.vim

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.

Generate/Update ctags and gtags will run in background.

Completion with gtags

gen_tags.vim also provide a gtags completion source for nvim-completion-manager
It's optional, if you don't use ncm, just ignore it πŸ˜„

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

  • Neobundle

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

  • 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 tags files, ext.conf and the folder.

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

    Clear GTAGS files

Key Mapping

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

The following mapping is set for GTAGS find function which use cscope interface (if_cscope).

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

Options

  • g:loaded_gentags#ctags

Set to 1 if you want to disable ctags support

  • g:loaded_gentags#gtags

Set to 1 if you want to disable gtags support

  • g:gen_tags#ctags_bin

Set location of ctags. The default is 'ctags'

  • g:gen_tags#ctags_opts

Set ctags options. The -R is set by default, so there is no need to add -R in g:gen_tags#ctags_opts.
The default g:gen_tags#ctags_opts is '', you need to set it in your vimrc πŸ˜„

  • g:gen_tags#ctags_use_cache_dir

This option only works for git-repo. Set the path of ctags tags. If this variable is set to 1, gen_tags.vim will use cache direcotry to store ctags tags.
The default g:gen_tags#ctags_use_cache_dir is 1, you need to set it in your vimrc.

0: SCM repo: git <project folder>/.git/tags_dir hg <project folder>/.hg/tags_dir svn <project folder>/.svn/tags_dir

non-git: $HOME/.cache/tags_dir/<project name>

1: $HOME/.cache/tags_dir/<project name>

  • g:gen_tags#gtags_split

Set gtags find display behavior. The default g:gtags_split is ''.
'' means don't split the display.
'h' means horizontal splitting.
'v' means vertical splitting.

  • g:gen_tags#ctags_auto_gen

Auto generate ctags when this variable is 1 and current file belongs to a scm repo.
The default g:gen_tags#ctags_auto_gen is 0

  • g:gen_tags#gtags_auto_gen

Auto generate gtags when this variable is 1 and current file belongs to a scm repo.
The default g:gen_tags#gtags_auto_gen is 0

  • g:gen_tags#blacklist

A list to set the blacklist, if the path in blacklist is equal gen_tags#find_project_root(), the generation of ctags/gtags will be skipped. The default g:gen_tags#blacklist is []

e.g.: You can set it in your vimrc as below, it will blacklist $HOME dir

let g:gen_tags#blacklist = ['$HOME']
  • g:gen_tags#verbose

Verbose mode to echo some message
The default g:gen_tags#verbose is 0

  • g:gen_tags#ctags_prune

Prune tags from tagfile before incremental update The default g:gen_tags#ctags_prune is 0


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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.