General lang refactor; new refactor, help, build & test menus

This commit is contained in:
Henrik Lissner 2017-10-03 02:49:49 +02:00
parent d0fcb23314
commit ed76cfda99
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
4 changed files with 87 additions and 67 deletions

View file

@ -4,45 +4,64 @@
:mode "\\.go$"
:interpreter "go"
:config
(setq gofmt-command "goimports")
(add-hook 'go-mode-hook #'flycheck-mode)
(setq gofmt-command "goimports")
(if (not (executable-find "goimports"))
(warn "go-mode: couldn't find goimports; no code formatting/fixed imports on save")
(add-hook! go-mode (add-hook 'before-save-hook #'gofmt-before-save nil t)))
(set! :build 'go-build 'go-mode #'+go/build)
(set! :repl 'go-mode #'gorepl-run)
(set! :jump 'go-mode
:definition #'go-guru-definition
:references #'go-guru-referrers
:documentation #'godoc-at-point)
(def-menu! +go/refactor-menu
"Refactoring commands for `go-mode' buffers."
'(("Add import" :exec go-import-add :region nil)
("Remove unused imports" :exec go-remove-unused-imports :region nil)
("Format buffer (gofmt)" :exec go-gofmt))
:prompt "Refactor: ")
(def-menu! +go/build-menu
"Build/compilation commands for `go-mode' buffers."
'(("Build project" :exec "go build")
("Build & run project" :exec "go run")
("Clean files" :exec "go clean"))
:prompt "Run test: ")
(def-menu! +go/test-menu
"Test commands for `go-mode' buffers."
'(("Last test" :exec +go/test-rerun)
("All tests" :exec +go/test-all)
("Single test" :exec +go/test-single)
("Nested test" :exec +go/test-nested))
:prompt "Run test: ")
(def-menu! +go/help-menu
"Help and information commands for `go-mode' buffers."
'(("Go to imports" :exec go-goto-imports)
("Lookup in godoc" :exec godoc-at-point)
("Describe this" :exec go-guru-describe)
("List free variables" :exec go-guru-freevars)
("What does this point to" :exec go-guru-pointsto)
("Implements relations for package types" :exec go-guru-implements :region nil)
("List peers for channel" :exec go-guru-peers)
("List references to object" :exec go-guru-referrers)
("Which errors" :exec go-guru-whicerrs)
("What query" :exec go-guru-what)
("Show callers of this function" :exec go-guru-callers :region nil)
("Show callees of this function" :exec go-guru-callees :region nil)))
(map! :map go-mode-map
:n "gd" #'go-guru-definition
:n "gD" #'go-guru-referrers
(:localleader
:n "gr" #'go-play-buffer
:v "gr" #'go-play-region
(:prefix "f"
:n "i" #'go-goto-imports
:n "h" #'godoc-at-point
:n "d" #'go-guru-describe
:n "v" #'go-guru-freevars
:n "I" #'go-guru-implements
:n "p" #'go-guru-peers
:n "r" #'go-guru-referrers
:n "t" #'go-guru-pointsto
:n "s" #'go-guru-callstack
:n "e" #'go-guru-whicherrs
:n "c" #'go-guru-callers
:n "C" #'go-guru-callees)
(:prefix "r"
:n "a" #'go-import-add
:n "i" #'go-remove-unused-imports
:nv "f" #'gofmt)
(:prefix "t"
:n "r" #'+go/test-rerun
:n "a" #'+go/test-all
:n "s" #'+go/test-single
:n "n" #'+go/test-nested))))
:localleader
"r" #'+go/refactor-menu
"b" #'+go/build-menu
"h" #'+go/help-menu
"t" #'+go/test-menu
:n "gr" #'go-play-buffer
:v "gr" #'go-play-region))
(def-package! go-eldoc