Skip to content

Instantly share code, notes, and snippets.

@dhellmann
Created September 4, 2020 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhellmann/1b2eab2b57dce50afbbe628d2f22c1c5 to your computer and use it in GitHub Desktop.
Save dhellmann/1b2eab2b57dce50afbbe628d2f22c1c5 to your computer and use it in GitHub Desktop.
(use-package go-mode
:ensure t
)
;; going to use a lot of go so go ahead and require it
(require 'go-mode)
;; gocode for autocompletion
;; https://github.com/mdempsky/gocode
(setq gocode-dir
(concat (getenv "HOME")
"/go/src/github.com/mdempsky/gocode")
)
(if (file-directory-p gocode-dir)
(progn
(load (concat gocode-dir "/emacs/go-autocomplete.el")
)
;;(require 'go-autocomplete)
)
)
;; Go mode hooks
(add-hook 'go-mode-hook
(lambda ()
(delete-selection-mode t)
;; Use goimports instead of go-fmt
;; http://tleyden.github.io/blog/2014/05/27/configure-emacs-as-a-go-editor-from-scratch-part-2/
(setq gofmt-command "goimports")
;; (turn-on-font-lock)
;; (setq fume-display-in-modeline-p nil)
(setq default-tab-width 4)
(setq tab-width 4)
;; via http://blog.devork.be/2011/09/small-emacs-tweaks-impoving-my-python.html
(subword-mode)
(linum-mode)
;; via http://dominik.honnef.co/posts/2013/03/writing_go_in_emacs/
(add-hook 'before-save-hook 'gofmt-before-save)
;; via http://tleyden.github.io/blog/2014/05/22/configure-emacs-as-a-go-editor-from-scratch/
(local-set-key (kbd "M-.") 'godef-jump)
(local-set-key (kbd "M-*") 'pop-tag-mark)
)
)
;; https://github.com/golang/lint
(setq golint-emacs-dir
(concat (getenv "HOME")
"/go/src/golang.org/x/lint/misc/emacs")
)
(if (file-directory-p golint-emacs-dir)
(progn
(add-to-list 'load-path golint-emacs-dir)
(require 'golint)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment