Here's how to use global
installed from a Ubuntu repository. The version I've had in 6.6.3-2.
First, copy the example config to your home directory. A commentary at its top makes it seem like this is unnecessary, but that's not true. The default config it has is much different, and doesn't recognize .rb
files at all, AFAICT.
cat /usr/share/doc/global/examples/gtags.conf.gz | gzip -d >~/.globalrc
Second, you need to choose the underlying mechanism. Pygments sounds great, but it generates "other symbol" entries, not definitions, which is what we normally need.
universal-ctags
might be the best choice, but the version of Global seems to need recompiling to use it (either the apt or the snap version). exuberant-ctags
works out of the box, though. The ancient version 5.9~svn20110310-1
.
Now, as explained in the documentation and in this issue, you would normally need to run gtags --gtagslabel=
in every gem directory:
for d in $(bundle list --paths); do
if [ -d $d ]; then
echo "$d";
(cd $d && find . -type f -name "*.rb" | gtags --gtagslabel=ctags -f -)
fi
done
The use of find
here is to avoid including JS files, etc, mostly because of the minified assets. But you can create a smarter enumeration.
To use the indexes from all these directories you need to set the env var GTAGSLIBPATH
to the appropriate value during an Emacs session. Given that it's different for every project, and even changes over time, maybe the best approach is to manually call a command in the project directory that will do that for you. Here's one you can use:
(defun set-gtagslibpath-to-bundle-paths ()
(interactive)
(let ((paths
(split-string
(with-output-to-string
(process-file-shell-command "bundle list --paths" nil
standard-output))
"\n")))
(while (and paths
(string-match-p "\\`The dependency'" (car paths)))
(setq paths (cdr paths)))
(setenv "GTAGSLIBPATH"
(mapconcat #'identity paths ":"))))
global
withctags
as its backend. With thatctags
will go the parsing butglobal
will save the database in its more efficient manner. Once you get that working from the terminal,ggtags
package will also work the same way. With that, this might not be an emacs related question at all.gtags
to runctags
with custom arguments? Can I configure it in.globalrc
~/.ctags
for ctags config and~/.globalrc
for global config. You need to specify the ctags binary location when building global: gnu.org/software/global/globaldoc_toc.html#Plug_002din