2014-06-04 04:03:05 +03:00
|
|
|
;;; prelude-go.el --- Emacs Prelude: Go programming support.
|
|
|
|
;;
|
|
|
|
;; Author: Doug MacEachern
|
2020-09-15 09:19:15 +03:00
|
|
|
;; URL: https://github.com/bbatsov/prelude
|
2014-06-04 04:03:05 +03:00
|
|
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; Prelude configuration for Go
|
|
|
|
|
|
|
|
;;; License:
|
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or
|
|
|
|
;; modify it under the terms of the GNU General Public License
|
|
|
|
;; as published by the Free Software Foundation; either version 3
|
|
|
|
;; of the License, or (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
|
|
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
;; Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(require 'prelude-programming)
|
|
|
|
|
|
|
|
(prelude-require-packages '(go-mode
|
|
|
|
company-go
|
|
|
|
go-eldoc
|
|
|
|
go-projectile
|
|
|
|
gotest))
|
|
|
|
|
|
|
|
(require 'go-projectile)
|
|
|
|
|
|
|
|
;; Ignore go test -c output files
|
|
|
|
(add-to-list 'completion-ignored-extensions ".test")
|
|
|
|
|
2014-06-18 03:55:42 +03:00
|
|
|
(define-key 'help-command (kbd "G") 'godoc)
|
|
|
|
|
2018-09-14 09:50:00 +03:00
|
|
|
(with-eval-after-load 'go-mode
|
|
|
|
(defun prelude-go-mode-defaults ()
|
|
|
|
;; Add to default go-mode key bindings
|
|
|
|
(let ((map go-mode-map))
|
|
|
|
(define-key map (kbd "C-c a") 'go-test-current-project) ;; current package, really
|
|
|
|
(define-key map (kbd "C-c m") 'go-test-current-file)
|
|
|
|
(define-key map (kbd "C-c .") 'go-test-current-test)
|
|
|
|
(define-key map (kbd "C-c b") 'go-run)
|
|
|
|
(define-key map (kbd "C-h f") 'godoc-at-point))
|
2014-06-04 04:03:05 +03:00
|
|
|
|
2018-09-14 09:50:00 +03:00
|
|
|
;; Prefer goimports to gofmt if installed
|
|
|
|
(let ((goimports (executable-find "goimports")))
|
|
|
|
(when goimports
|
|
|
|
(setq gofmt-command goimports)))
|
2014-06-04 04:03:05 +03:00
|
|
|
|
2018-09-14 09:50:00 +03:00
|
|
|
;; gofmt on save
|
|
|
|
(add-hook 'before-save-hook 'gofmt-before-save nil t)
|
2014-06-04 04:03:05 +03:00
|
|
|
|
2018-09-14 09:50:00 +03:00
|
|
|
;; stop whitespace being highlighted
|
|
|
|
(whitespace-toggle-options '(tabs))
|
2014-06-04 04:03:05 +03:00
|
|
|
|
2018-09-14 09:50:00 +03:00
|
|
|
;; Company mode settings
|
|
|
|
(set (make-local-variable 'company-backends) '(company-go))
|
2014-06-04 04:03:05 +03:00
|
|
|
|
2018-09-14 09:50:00 +03:00
|
|
|
;; El-doc for Go
|
|
|
|
(go-eldoc-setup)
|
2014-06-04 04:03:05 +03:00
|
|
|
|
2018-09-14 09:50:00 +03:00
|
|
|
;; CamelCase aware editing operations
|
|
|
|
(subword-mode +1))
|
2014-06-04 04:03:05 +03:00
|
|
|
|
2018-09-14 09:50:00 +03:00
|
|
|
(setq prelude-go-mode-hook 'prelude-go-mode-defaults)
|
2014-06-04 04:03:05 +03:00
|
|
|
|
2018-09-14 09:50:00 +03:00
|
|
|
(add-hook 'go-mode-hook (lambda ()
|
|
|
|
(run-hooks 'prelude-go-mode-hook))))
|
2014-06-04 04:03:05 +03:00
|
|
|
|
|
|
|
(provide 'prelude-go)
|
|
|
|
;;; prelude-go.el ends here
|