go: add option in refactoring to fill a structure with default values

This commit is contained in:
Cosmin Cojocar 2018-03-30 18:39:46 +02:00 committed by syl20bnr
parent ae53d9612e
commit 80dbae3825
2 changed files with 20 additions and 9 deletions

View File

@ -45,6 +45,7 @@ You will need =gocode=, =gogetdoc=, =godef= and =godoctor=:
go get -u -v github.com/zmb3/gogetdoc
go get -u -v github.com/cweill/gotests/...
go get -u github.com/haya14busa/gopkgs/cmd/gopkgs
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct
#+END_SRC
If you wish to use =gometalinter= set the value of =go-use-gometalinter= to t:
@ -211,12 +212,14 @@ You have a few options to ensure you always get up to date suggestions:
** Refactoring
| Key Binding | Description |
|-------------+-----------------------------------|
| ~SPC m r d~ | Add comment stubs |
| ~SPC m r e~ | Extract code as new function |
| ~SPC m r f~ | Add field tags |
| ~SPC m r F~ | Remove field tags |
| ~SPC m r n~ | Rename (with =godoctor=) |
| ~SPC m r N~ | Rename (with =go-rename=) |
| ~SPC m r t~ | Toggle declaration and assignment |
| Key Binding | Description |
|-------------+------------------------------------|
| ~SPC m r d~ | Add comment stubs |
| ~SPC m r e~ | Extract code as new function |
| ~SPC m r f~ | Add field tags |
| ~SPC m r F~ | Remove field tags |
| ~SPC m r n~ | Rename (with =godoctor=) |
| ~SPC m r N~ | Rename (with =go-rename=) |
| ~SPC m r N~ | Rename (with =go-rename=) |
| ~SPC m r s~ | Fill structure with default values |
| ~SPC m r t~ | Toggle declaration and assignment |

View File

@ -28,6 +28,7 @@
godoctor
go-tag
popwin
go-fill-struct
))
@ -133,6 +134,13 @@
"rf" 'go-tag-add
"rF" 'go-tag-remove)))
(defun go/init-go-fill-struct ()
(use-package go-fill-struct
:init
(spacemacs/declare-prefix-for-mode 'go-mode "mr" "refactoring")
(spacemacs/set-leader-keys-for-major-mode 'go-mode
"rs" 'go-fill-struct)))
(defun go/init-flycheck-gometalinter ()
(use-package flycheck-gometalinter
:defer t