GNU Global 实践
Table of Contents
1 概述
主要讲述 gtags 命令的使用。其他详见 gnu global 用户手册 。
2 安装
先安装插件:
2.1 Universal Ctags
由于 Darren Hiebert 的 Exuberant-ctags 项目停滞不前, 有人创建 universal-ctags 继续开发。
git clone git@github.com:universal-ctags/ctags.git
cd ctags
./autogen.sh
./configure
make && sudo make install
2.2 pygments
sudo pip install pygments
2.3 安装 global
当前版本:
global (GNU GLOBAL) 6.6.3 Powered by Berkeley DB 1.85. Copyright (c) 1996-2018 Tama Communications Corporation License GPLv3+: GNU GPL version 3 or later <http://www.gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
安装:
./configure --with-universal-ctags=/usr/local/bin/ctags make && sudo make install
3 配置
3.1 解析器插件
plugin-factory/
目录下面保存了可以使用的插件。现在默认安装了三种插件:
Nop parser('user-custom.c')
A skeleton parser. 啥都没有实现。
Universal Ctags('exuberant-ctags.c')
使用Universal Ctags 作为解析器。
Pygments + Universal Ctags ('pygments-parser.c')
Pygments 支持各种编程语言的语法高亮。 该插件使用 Pygments 和 Exuberant Ctags 作为解析器来处理定义和引用。
4 使用
4.1 生成 tags
--gtagslabel=pygments
执行解析方式。--explain
显示 gtags 使用的解析库。
gtags --explain --gtagslabel=pygments
...
File './lib/xmalloc.c' is handled as follows:
suffix: |.c|
language: |C|
parser: |parser|
library: |/usr/local/lib/gtags/pygments-parser.la|
----------------------------------