Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.5 KiB

12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
  1. ;;; prelude-go.el --- Emacs Prelude: Go programming support.
  2. ;;
  3. ;; Author: Doug MacEachern
  4. ;; Version: 1.0.0
  5. ;; Keywords: convenience go
  6. ;; This file is not part of GNU Emacs.
  7. ;;; Commentary:
  8. ;; Prelude configuration for Go
  9. ;;; License:
  10. ;; This program is free software; you can redistribute it and/or
  11. ;; modify it under the terms of the GNU General Public License
  12. ;; as published by the Free Software Foundation; either version 3
  13. ;; of the License, or (at your option) any later version.
  14. ;;
  15. ;; This program is distributed in the hope that it will be useful,
  16. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;; GNU General Public License for more details.
  19. ;;
  20. ;; You should have received a copy of the GNU General Public License
  21. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  22. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  23. ;; Boston, MA 02110-1301, USA.
  24. ;;; Code:
  25. (require 'prelude-programming)
  26. (prelude-require-packages '(go-mode
  27. company-go
  28. go-eldoc
  29. go-projectile
  30. gotest))
  31. (require 'go-projectile)
  32. ;; Ignore go test -c output files
  33. (add-to-list 'completion-ignored-extensions ".test")
  34. (define-key 'help-command (kbd "G") 'godoc)
  35. (with-eval-after-load 'go-mode
  36. (defun prelude-go-mode-defaults ()
  37. ;; Add to default go-mode key bindings
  38. (let ((map go-mode-map))
  39. (define-key map (kbd "C-c a") 'go-test-current-project) ;; current package, really
  40. (define-key map (kbd "C-c m") 'go-test-current-file)
  41. (define-key map (kbd "C-c .") 'go-test-current-test)
  42. (define-key map (kbd "C-c b") 'go-run)
  43. (define-key map (kbd "C-h f") 'godoc-at-point))
  44. ;; Prefer goimports to gofmt if installed
  45. (let ((goimports (executable-find "goimports")))
  46. (when goimports
  47. (setq gofmt-command goimports)))
  48. ;; gofmt on save
  49. (add-hook 'before-save-hook 'gofmt-before-save nil t)
  50. ;; stop whitespace being highlighted
  51. (whitespace-toggle-options '(tabs))
  52. ;; Company mode settings
  53. (set (make-local-variable 'company-backends) '(company-go))
  54. ;; El-doc for Go
  55. (go-eldoc-setup)
  56. ;; CamelCase aware editing operations
  57. (subword-mode +1))
  58. (setq prelude-go-mode-hook 'prelude-go-mode-defaults)
  59. (add-hook 'go-mode-hook (lambda ()
  60. (run-hooks 'prelude-go-mode-hook))))
  61. (provide 'prelude-go)
  62. ;;; prelude-go.el ends here