Importing the Pygments parser into GNU GLOBAL should make source code reading incredible
A very useful function was introduced, so I wrote the Linux version. (The above is a Mac) Finally, the settings for Emacs are also posted.
Please check here for the latest version. Getting GLOBAL
homebrew or linuxbrew
brew install global
Source installation
VERSION=6.4
wget http://tamacom.com/global/global-${VERSION}.tar.gz
tar xvf global-${VERSION}.tar.gz
cd global-${VERSION}
./configure
make
make install
cp /usr/local/share/gtags/gtags.conf /etc/
You don't need to modify gtags.conf this time, but if the path to pygments-parser.la is different, modify it accordingly.
If you want to specify the GNU GLOBAL settings for each user, you can overwrite the settings by placing gtags.conf
in $ HOME / .globalrc
.
For Linux, I think most distributions have it pre-installed. If it is not installed, install Python from the package manager of each distribution.
I have confirmed the operation with Python 2.6.6.
pip is a package management system for installing and managing packaged software written in Python.
curl -kL https://bootstrap.pypa.io/get-pip.py | python
Pygments is a syntax highlighter for various languages.
pip install pygments
Please refer to here for tag generation and tag reference. Importing the Pygments parser into GNU GLOBAL should make source code reading incredible
As far as I can see, tag generation was successful in all of Ruby, Python, and Go, but only referencing Go tags using the global
command did not work.
(Nothing is output as standard when executed)
However, since the Go tag reference is successful from the following helm-g tags, it seems that only the tag reference from the global
command does not work.
-How to use the GNU GLOBAL (gtags) source code tag system
gtags.vim
and gtags.el
are located in / usr / local / share / gtags /
.
ll /usr/local/share/gtags/gtags.{vim,el}
-rw-r--r-- 1 root root 36494 Sep 17 19:50 /usr/local/share/gtags/gtags.el
-rw-r--r-- 1 root root 16170 Sep 17 19:50 /usr/local/share/gtags/gtags.vim
+α for Emacs
In the above, gtags.el is introduced, but here is a more convenient helm-gtags.el. Please install Emacs 24.3, helm, helm-gtags, go-mode.
Click here for helm-gtags. helm-gtags - Emacs JP
(require 'helm-gtags)
(add-hook 'go-mode-hook (lambda () (helm-gtags-mode)))
(add-hook 'python-mode-hook (lambda () (helm-gtags-mode)))
(add-hook 'ruby-mode-hook (lambda () (helm-gtags-mode)))
(setq helm-gtags-path-style 'root)
(setq helm-gtags-auto-update t)
(add-hook 'helm-gtags-mode-hook
'(lambda ()
(local-set-key (kbd "M-g") 'helm-gtags-dwim)
(local-set-key (kbd "M-s") 'helm-gtags-show-stack)
(local-set-key (kbd "M-p") 'helm-gtags-previous-history)
(local-set-key (kbd "M-n") 'helm-gtags-next-history)))
After that, you can start Emacs, move the cursor to the target, and jump the function with M-g.
The image at the top of the page is Emacs + helm-gtags, which refers to the Go tag.
Now you can jump functions in Python, Ruby, and Go without any special Emacs settings by executing the gtags command once!
I'm impressed.
-Importing the Pygments parser into GNU GLOBAL should make the source code reading incredibly fast -Use Pygments to significantly increase the languages supported by GNU GLOBAL | Passion of an engineer
Recommended Posts