From a7ff1ee13338a3e4feaf5301b2ea751fb520367a Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Thu, 6 Oct 2016 18:07:53 +0530 Subject: [PATCH] Emacs: Add go-eldoc and go-guru --- .emacs.d/init.el | 2 ++ .emacs.d/lisp/main.el | 2 ++ .emacs.d/lisp/mode-go.el | 10 +++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index bb762c96..2ea4fbaf 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -118,6 +118,8 @@ To view where the bindings are set in your config files, lookup (load-external "\\.vert\\'\\|\\.frag\\'\\|\\.glsl\\'" 'glsl-mode nil 'c-mode) (add-to-list 'favorite-packages 'go-mode) +(add-to-list 'favorite-packages 'go-eldoc) +(add-to-list 'favorite-packages 'go-guru) (add-to-list 'favorite-packages 'go-rename) (add-to-list 'favorite-packages 'helm-go-package) (load-external "\\.go\\'" 'go-mode) diff --git a/.emacs.d/lisp/main.el b/.emacs.d/lisp/main.el index 2a220785..7e5f9e88 100644 --- a/.emacs.d/lisp/main.el +++ b/.emacs.d/lisp/main.el @@ -347,6 +347,8 @@ ;; Replace not-so-useful comment-dwim binding. (define-key mickey-minor-mode-map "\M-;" 'comment-line) +; In case you find eldoc too distracting. +;; (global-eldoc-mode 0) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (provide 'main) diff --git a/.emacs.d/lisp/mode-go.el b/.emacs.d/lisp/mode-go.el index dc00a855..d5d237ec 100644 --- a/.emacs.d/lisp/mode-go.el +++ b/.emacs.d/lisp/mode-go.el @@ -1,7 +1,6 @@ ;;============================================================================== ;; Go ;;============================================================================== -;; Optional packages: go-autocomplete?, go-complete?, go-guru (defun go-eval-buffer () "Eval buffer with `go run'." @@ -21,6 +20,13 @@ (and looping (not (string= dir "/"))))) (if (string= dir "/") nil t)))) +(when (require 'go-guru nil t) + (unless (executable-find "guru") + ; Requires `call-process-to-string' from `functions'." + (require 'functions) + (setq go-guru-command + (concat (replace-regexp-in-string "\n$" "" (call-process-to-string "go" "env" "GOTOOLDIR")) "/guru")))) + (add-hook 'godoc-mode-hook (lambda () @@ -29,6 +35,8 @@ (add-hook-and-eval 'go-mode-hook (lambda () + (when (require 'go-eldoc nil t) + (go-eldoc-setup)) (setq gofmt-command "goimports") (setq godoc-command "godoc -ex") (setq godoc-and-godef-command "godoc -ex")