Skip to content

Commit 6e1072e

Browse files
committed
Merge pull request #757 from mhamrle/generate
syntax highlighting for //go:generate
2 parents 1c581cb + 0bd3f9a commit 6e1072e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

syntax/go.vim

+12-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ if !exists("g:go_highlight_string_spellcheck")
8181
let g:go_highlight_string_spellcheck = 1
8282
endif
8383

84+
if !exists("g:go_highlight_generate_tags")
85+
let g:go_highlight_generate_tags = 0
86+
endif
87+
8488
syn case match
8589

8690
syn keyword goDirective package import
@@ -132,11 +136,18 @@ hi def link goBoolean Boolean
132136
syn keyword goTodo contained TODO FIXME XXX BUG
133137
syn cluster goCommentGroup contains=goTodo
134138
syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell
135-
syn region goComment start="//" end="$" contains=@goCommentGroup,@Spell
139+
syn region goComment start="//" end="$" contains=goGenerate,@goCommentGroup,@Spell
136140

137141
hi def link goComment Comment
138142
hi def link goTodo Todo
139143

144+
if g:go_highlight_generate_tags != 0
145+
syn match goGenerateVariables contained /\(\$GOARCH\|\$GOOS\|\$GOFILE\|\$GOLINE\|\$GOPACKAGE\|\$DOLLAR\)\>/
146+
syn region goGenerate start="^\s*//go:generate" end="$" contains=goGenerateVariables
147+
hi def link goGenerate PreProc
148+
hi def link goGenerateVariables Special
149+
endif
150+
140151
" Go escapes
141152
syn match goEscapeOctal display contained "\\[0-7]\{3}"
142153
syn match goEscapeC display contained +\\[abfnrtv\\'"]+

0 commit comments

Comments
 (0)