@@ -24,7 +24,7 @@ set-variable .fhook-go.setup ® "/history/fhook/go" "bdfghnopxlqv"
24
24
set-variable .fhook-go.setup-mask "abdefghikmnoptuxclqrvy"
25
25
set-variable .fhook-go.comment "|/*| */|*| * | * |f|"
26
26
set-variable .fhook-go.comment-1 "|//||//|// | //|r|"
27
- set-variable .fhook-go.indent-width 4
27
+ set-variable .fhook-go.indent-width 8
28
28
29
29
; Setup collapse
30
30
set-variable .fhook-go.collapse-open "^\\(func\\|type\\)"
@@ -35,11 +35,11 @@ set-variable .fhook-go.item-list-s1 "^\\s*\\(func\\|type\\)\\s+\\(.+\\)\\s+{"
35
35
set-variable .fhook-go.item-list-r1 "\\1 \ecB\\2\ecA"
36
36
37
37
; Setup Commands
38
- set-variable .fhook-go.command-flag "|t|th|th|"
39
- set-variable .fhook-go.command-name "||gofmt|gomake |"
40
- set-variable .fhook-go.command-nbind "||||"
41
- set-variable .fhook-go.command-kbind "||||"
42
- set-variable .fhook-go.command-desc "||Go \HFormat|Go \HMake |"
38
+ set-variable .fhook-go.command-flag "|t|th|th|th|th| "
39
+ set-variable .fhook-go.command-name "||gofmt|goimports|gobuild|gorun |"
40
+ set-variable .fhook-go.command-nbind "|||||| "
41
+ set-variable .fhook-go.command-kbind "|||||| "
42
+ set-variable .fhook-go.command-desc "||Go \HFormat|Go \HImports|Go \HBuild|Go \HRun |"
43
43
44
44
!if ¬ &exist .hilight.go
45
45
set-variable .hilight.go &pinc .hilight.next 1
@@ -156,12 +156,52 @@ set-variable .fhook-go.command-desc "||Go \HFormat|Go \HMake|"
156
156
indent .hilight.go c "/$" t
157
157
!endif
158
158
159
+ ;define-macro gofmt
160
+ ; filter-buffer "gofmt -w"
161
+ ; ; DANGER would like to save-buffer auto here, but if gofmt hits an error
162
+ ; ; the output of filter-buffer is empty, nuking your file! Need some logic
163
+ ; ; here to detect empty filter-buffer?
164
+ ; ;save-buffer
165
+ ;!emacro
166
+
159
167
define-macro gofmt
160
- filter-buffer "gofmt"
168
+ set-variable .file $buffer-bname
169
+ ;filter-buffer "gofmt"
170
+ 5 shell-command &cat "gofmt -w " .file
171
+
172
+ !if &equ $result 0
173
+ 0 reread-file
174
+ ;save-buffer
175
+ !endif
176
+ !emacro
177
+
178
+ define-macro goimports
179
+ set-variable .file $buffer-bname
180
+ ;filter-buffer "goimports"
181
+ 5 shell-command &cat "goimports -w " .file
182
+
183
+ !if &equ $result 0
184
+ 0 reread-file
185
+ ;save-buffer
186
+ !endif
161
187
!emacro
162
188
163
- define-macro gomake
164
- compile "gomake"
189
+ define-macro gobuild
190
+ set-variable .file $buffer-bname
191
+ compile &cat "go build " .file
192
+ ; delete-other-windows
193
+ !emacro
194
+
195
+ define-macro gorun
196
+ set-variable .file $buffer-bname
197
+ compile &cat "go run " .file
165
198
!emacro
166
199
167
200
buffer-init-fhook "go"
201
+
202
+ ; Useful shortcuts
203
+ global-bind-key "gofmt" "esc A-f"
204
+ global-bind-key "goimports" "esc A-i"
205
+ global-bind-key "gobuild" "esc A-b"
206
+ global-bind-key "gorun" "esc A-r"
207
+ global-bind-key "delete-other-windows" "esc f1"
0 commit comments