I use Emacs for Go development and I really like it.

To set up Emacs for Go I use Guillaume J. Charmes’ setup as a base. I do additional tweaks and modifications to that setup. His setup is for Macintosh and I tried running it on my Antergos Linux at home but it didn’t work out of the box. Antergos is Arch based Linux distro that I use and recommend.

To setup on Mac start by cloning Guillaume’s repo:

git clone https://github.com/creack/dotfiles ~/.dotfiles
cd ~/.dotfiles

Edit the .Brewfile and remove applications that should not be installed.

Run the initialization script:

./bootstrap.sh

The basic setup is now done and we can test it by verifying that the autocomplete feature works:

Emacs autocomplete for Go

After that I add other Emacs modules that I like and use.

I use helm-git-grep.el a lot. It helps me in finding things fast. I use the following key binding for Helm Git Grep:

(global-set-key (kbd "C-x e") 'helm-grep-do-git-grep)

And here it is - the power of Helm Git Grep:

Helm Git grep in action

I also use Helm Recentf a lot.

I cannot live without Org mode. I setup it like this:

;; set key for agenda
(global-set-key (kbd "C-c a") 'org-agenda)
;;file to save todo items
(setq org-agenda-files (quote ("/Users/donchevl/work/NOTES.org")))
;;set priority range from A to C with default A
(setq org-highest-priority ?A)
(setq org-lowest-priority ?C)
(setq org-default-priority ?A)
;;set colours for priorities
(setq org-priority-faces '((?A . (:foreground "#F0DFAF" :weight bold))
(?B . (:foreground "LightSteelBlue"))
(?C . (:foreground "OliveDrab"))))
;;open agenda in current window
(setq org-agenda-window-setup (quote current-window))
;;capture todo items using C-c c t
(define-key global-map (kbd "C-c c") 'org-capture)
(setq org-capture-templates
'(("t" "todo" entry (file+headline "/Users/donchevl/work/NOTES.org" "Tasks")
"* TODO [#A] %?")))

The shell switcher module is another thing that I cannot live without:

(require 'shell-switcher)
(setq shell-switcher-mode t)

Ace Jump helps me in using only the keyboard when navigating source code:

autoload
'ace-jump-mode
"ace-jump-mode"
"Emacs quick move minor mode"
t)
(require 'ace-isearch)
(global-ace-isearch-mode +1)

And I also setup the following key bindings:

(global-set-key (kbd "C-x m") 'helm-recentf)
(global-set-key (kbd "C-h SPC") 'helm-all-mark-rings)
(global-set-key (kbd "C-c i b") 'helm-browse-project)
(global-set-key (kbd "C-x e") 'helm-grep-do-git-grep)
(global-set-key (kbd "C-x l") 'helm-ls-git-ls)
(global-set-key (kbd "C-c i c") 'compilation-mode)
(global-set-key (kbd "C-c i s") 'helm-multi-swoop-all)

Emacs is amazing piece of engineering. Start using it now.

Comments

2019-01-04