如何将Python插件添加到Gnu Global

发布于 2024-11-01 09:59:56 字数 647 浏览 0 评论 0原文

我的 gtags 版本是 gtags - GNU GLOBAL 5.9.2

我下载了 Gnu Global 的 python 插件 这里

将globalrc.example复制到~/.globalrc

将script/python_global_tags.py复制到~/bin/python_global_tags.py,它位于我的$PATH

类型中:python目录中的“gtags”文件

没有抱怨

类型:“global -f test.py”

没有输出

,但“global -g”有效,我想知道它是否只是 grep 的包装

我的问题是:

  • 是否有可能在 python 本身中编写一个插件?
  • 有没有配置 ~/.globalrc 的教程,官方站点中的教程提到很少那。

非常感谢,

gnu global 正在崛起,但仍然支持很少的语言

my gtags verion is gtags - GNU GLOBAL 5.9.2

I downloaded a python plug-in for Gnu Global here

copy the globalrc.example to ~/.globalrc

copy the script/python_global_tags.py to ~/bin/python_global_tags.py which is in my $PATH

type: "gtags" in a directory of python files

no complain

type: "global -f test.py"

no output

but "global -g" works, I wander if it is just a wrapper of grep

My Question is:

  • Is it even possible to write a plugin in python itself?
  • Is there a tutorial for configuring the ~/.globalrc, tutoials in offical site mention so little about that.

Thanks a lot,

gnu global is rising, but still supports so few languages btw

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别在捏我脸啦 2024-11-08 09:59:56

对于那些通过 Google 到达此页面的人:现在 GNU Global 通过一个基于 Pygments 的精彩插件支持 Python(以及更多):

https://github.com/yoshizow/global-pygments-plugin

只需按照自述文件操作即可,唯一的注意事项是,在我的情况下,gtags 为大文件生成了空文件文件树,可能是由于大量使用符号链接;解决方案是按照手册中的建议使用find /a>:

find . -name '*.py' >/tmp/list     # make a file set
gtags -f /tmp/list                 # and use it

现在可以搜索定义

global -x main     # suppose you have at least one main() somewhere in the code

或引用

global -rsx sys                    # this is likely to list *all* your modules

,甚至可以搜索不完整标签的可能补全:

global -cs OrderedD                # -c: "complete", -s: "non-local references"

Just for those arriving at this page via Google: now GNU Global does support Python (and more) via a wonderful Pygments-based plugin:

https://github.com/yoshizow/global-pygments-plugin

Just follow the README, the only note is that in my case gtags produced empty files for big file trees, possibly due to heavy use of symlinks; the solution is to use find as advised in the manual:

find . -name '*.py' >/tmp/list     # make a file set
gtags -f /tmp/list                 # and use it

Now one can either search for definitions

global -x main     # suppose you have at least one main() somewhere in the code

or references

global -rsx sys                    # this is likely to list *all* your modules

or even search for possible completions for incomplete tags:

global -cs OrderedD                # -c: "complete", -s: "non-local references"
梦屿孤独相伴 2024-11-08 09:59:56

据我了解,GNU Global 还不支持 Python。主页上说:

支持C、C++、Yacc、Java、PHP4和汇编。 (定义和
参考)

这篇文章基本上说我们需要用 C 语言编写一个插件。由于不支持全局,我又回到了旧的 Exuberant Ctags

ctags -e -R .

效果很好,但你没有得到反向引用。另请参阅有关 etag 的其他问题

From what I understand, GNU Global doesn't support Python yet. The homepage says:

support C, C++, Yacc, Java, PHP4 and assembly. (definition and
reference)

And this post basically says we would need to write a plugin in C. Since global is not supported, I reverted back to the good old Exuberant Ctags:

ctags -e -R .

Works well, but you don't get backreferences. See also this other question about etags.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文