[LINUX] GNU GLOBAL (gtags) + α in Go, Ruby, Python

global.png

Overview

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.

GNU GLOBAL installation

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

GNU GLOBAL settings

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.

Python installation

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 installation

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

Install Pygments

Pygments is a syntax highlighter for various languages.

pip install pygments

Operation check

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 GNU GLOBAL from commands, Vim, Emacs

-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.

reference

-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

GNU GLOBAL (gtags) + α in Go, Ruby, Python
Grouping combination in Python / Ruby / PHP / Golang (Go)
Handle prime numbers in Python / Ruby / PHP / Golang (Go)
Overlapping combinations with limits in Python / Ruby / PHP / Golang (Go)
Factorial, permutations, (duplicate) combinations in Python / Ruby / PHP / Golang (Go)
Multi-stage selection (Go / C # / Ruby / Python)
Using global variables in python functions
[Python3] Dynamically define global variables in functions
Differences between Ruby and Python in scope
Big difference in ruby, python, httpd performance
[Scraping Summary] | Python Node.js PHP Ruby Go VBA | Scraping Yahoo! Top in 6 languages
Difference between nonlocal and global in Python
Referencing INI files in Python or Ruby
Try something like Python for-else in Ruby
How to write Ruby to_s in Python
Implemented memoization recursion and exploration in Python and Go
Install Python 3.5.1 + numpy + scipy + α in Windows environment
Practice applying functions and global variables in Python
Y / n processing in bash, python and Go
Create a package containing global commands in Python
Regular expression symbolic group name in Python / Ruby
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Unittest in python
Python with Go
Epoch in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Rock-paper-scissors in Ruby
Sqlite in python
StepAIC in Python
This Week's Algorithm: Shortest Path Calculation! (Permutation iterator in Ruby / Python / C # / VB / Go)
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python