How to add Python plug-in to Gnu Global
Asked Answered
K

2

7

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

Kurd answered 14/4, 2011 at 9:57 Comment(1)
apparently this question was also posted on the help-global mailing list, and it received one answer there. Here's the link for anyone interested: lists.gnu.org/archive/html/help-global/2011-04/msg00001.htmlIndoors
P
9

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"
Pedestrianism answered 21/7, 2016 at 12:31 Comment(0)
P
0

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.

Phyllous answered 18/1, 2013 at 20:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.