2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/go/config.el -*- lexical-binding: t; -*-
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2018-03-02 19:55:03 -05:00
|
|
|
;;
|
2019-09-13 21:59:03 -04:00
|
|
|
;;; Packages
|
2018-03-01 00:55:58 -05:00
|
|
|
|
2018-05-25 00:46:11 +02:00
|
|
|
(after! go-mode
|
feature/lookup: rewrite dash docset integration
+ Uses alist variable to store config, rather than hooks
+ Added check for installed docsets in +lookup/documentation
+ Set docsets for various language modules (c-mode, c++-mode, css-mode,
scss-mode, sass-mode, web-mode, go-mode, racket-mode, emacs-lisp-mode,
js2-mode, rjsx-mode, typescript-mode, rust-mode, and php-mode)
+ Made *eww* popups for dash docsets larger
+ Renamed set-docset! => set-docsets! (set-docset! is aliased to
set-docsets!)
+ New +lookup/install-docset alias
2018-08-31 02:44:49 +02:00
|
|
|
(set-docsets! 'go-mode "Go")
|
2018-06-15 16:07:24 +02:00
|
|
|
(set-repl-handler! 'go-mode #'gorepl-run)
|
2018-06-15 17:27:48 +02:00
|
|
|
(set-lookup-handlers! 'go-mode
|
2017-10-03 02:49:49 +02:00
|
|
|
:definition #'go-guru-definition
|
|
|
|
:references #'go-guru-referrers
|
|
|
|
:documentation #'godoc-at-point)
|
|
|
|
|
2018-09-08 23:47:44 -04:00
|
|
|
;; Redefines default formatter to *not* use goimports if reformatting a
|
|
|
|
;; region; as it doesn't play well with partial code.
|
|
|
|
(set-formatter! 'gofmt
|
2018-09-18 13:14:39 -04:00
|
|
|
'(("%s" (if (or +format-region-p
|
2018-09-08 23:47:44 -04:00
|
|
|
(not (executable-find "goimports")))
|
|
|
|
"gofmt"
|
|
|
|
"goimports"))))
|
2018-05-25 00:46:11 +02:00
|
|
|
|
2019-07-02 23:23:28 +03:00
|
|
|
(if (featurep! +lsp)
|
|
|
|
(add-hook 'go-mode-local-vars-hook #'lsp!)
|
|
|
|
(add-hook 'go-mode-hook #'go-eldoc-setup))
|
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(map! :map go-mode-map
|
2017-10-03 02:49:49 +02:00
|
|
|
:localleader
|
2019-11-06 14:22:24 +01:00
|
|
|
"a" #'go-tag-add
|
|
|
|
"d" #'go-tag-remove
|
2018-12-23 23:54:27 -05:00
|
|
|
"e" #'+go/play-buffer-or-region
|
|
|
|
"i" #'go-goto-imports ; Go to imports
|
2018-12-26 16:57:53 +00:00
|
|
|
(:prefix ("h" . "help")
|
2018-12-23 23:54:27 -05:00
|
|
|
"." #'godoc-at-point ; Lookup in godoc
|
|
|
|
"d" #'go-guru-describe ; Describe this
|
|
|
|
"v" #'go-guru-freevars ; List free variables
|
|
|
|
"i" #'go-guru-implements ; Implements relations for package types
|
|
|
|
"p" #'go-guru-peers ; List peers for channel
|
|
|
|
"P" #'go-guru-pointsto ; What does this point to
|
|
|
|
"r" #'go-guru-referrers ; List references to object
|
|
|
|
"e" #'go-guru-whicherrs ; Which errors
|
|
|
|
"w" #'go-guru-what ; What query
|
|
|
|
"c" #'go-guru-callers ; Show callers of this function
|
|
|
|
"C" #'go-guru-callees) ; Show callees of this function
|
2018-12-26 16:57:53 +00:00
|
|
|
(:prefix ("ri" . "imports")
|
2018-12-23 23:54:27 -05:00
|
|
|
"a" #'go-import-add
|
|
|
|
"r" #'go-remove-unused-imports)
|
2020-03-27 01:25:30 -04:00
|
|
|
(:prefix ("b" . "build")
|
2020-06-04 20:02:46 -04:00
|
|
|
:desc "go run ." "r" (cmd! (compile "go run ."))
|
|
|
|
:desc "go build" "b" (cmd! (compile "go build"))
|
|
|
|
:desc "go clean" "c" (cmd! (compile "go clean")))
|
2018-12-26 16:57:53 +00:00
|
|
|
(:prefix ("t" . "test")
|
2018-12-23 23:54:27 -05:00
|
|
|
"t" #'+go/test-rerun
|
|
|
|
"a" #'+go/test-all
|
|
|
|
"s" #'+go/test-single
|
2019-10-22 12:35:12 -04:00
|
|
|
"n" #'+go/test-nested
|
|
|
|
"g" #'go-gen-test-dwim
|
|
|
|
"G" #'go-gen-test-all
|
2020-02-09 17:00:28 -05:00
|
|
|
"e" #'go-gen-test-exported
|
|
|
|
(:prefix ("b" . "bench")
|
|
|
|
"s" #'+go/bench-single
|
|
|
|
"a" #'+go/bench-all))))
|
|
|
|
|
2017-03-19 22:49:00 -04:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! gorepl-mode
|
2018-05-25 00:46:11 +02:00
|
|
|
:commands gorepl-run-load-current-file)
|
2017-05-26 11:44:06 +02:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! company-go
|
2019-09-13 21:59:03 -04:00
|
|
|
:when (featurep! :completion company)
|
|
|
|
:unless (featurep! +lsp)
|
2017-03-16 17:40:45 -04:00
|
|
|
:after go-mode
|
2017-05-26 02:13:47 +02:00
|
|
|
:config
|
2018-06-15 02:58:12 +02:00
|
|
|
(set-company-backend! 'go-mode 'company-go)
|
2018-05-25 00:46:11 +02:00
|
|
|
(setq company-go-show-annotation t))
|
2019-10-30 09:36:05 +01:00
|
|
|
|
|
|
|
(use-package! flycheck-golangci-lint
|
2020-01-14 03:04:26 -05:00
|
|
|
:when (featurep! :checkers syntax)
|
2019-12-01 20:45:13 +01:00
|
|
|
:hook (go-mode . flycheck-golangci-lint-setup))
|