diff options
Diffstat (limited to 'syntax/go.vim')
-rw-r--r-- | syntax/go.vim | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/syntax/go.vim b/syntax/go.vim index 1bca27c2..c4861715 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -108,6 +108,8 @@ else syn region goRawString start=+`+ end=+`+ endif +syn match goImportString /^\%(\s\+\|import \)\(\h\w* \)\?\zs"[^"]\+"$/ contained containedin=goImport + if go#config#HighlightFormatStrings() " [n] notation is valid for specifying explicit argument indexes " 1. Match a literal % not preceded by a %. @@ -125,6 +127,7 @@ if go#config#HighlightFormatStrings() hi def link goFormatSpecifier goSpecialString endif +hi def link goImportString String hi def link goString String hi def link goRawString String @@ -144,9 +147,9 @@ endif " import if go#config#FoldEnable('import') - syn region goImport start='import (' end=')' transparent fold contains=goImport,goString,goComment + syn region goImport start='import (' end=')' transparent fold contains=goImport,goImportString,goComment else - syn region goImport start='import (' end=')' transparent contains=goImport,goString,goComment + syn region goImport start='import (' end=')' transparent contains=goImport,goImportString,goComment endif " var, const @@ -277,10 +280,11 @@ hi def link goOperator Operator " Functions; if go#config#HighlightFunctions() || go#config#HighlightFunctionParameters() syn match goDeclaration /\<func\>/ nextgroup=goReceiver,goFunction,goSimpleParams skipwhite skipnl + syn match goReceiverDecl /(\s*\zs\%(\%(\w\+\s\+\)\?\*\?\w\+\)\ze\s*)/ contained contains=goReceiverVar,goReceiverType,goPointerOperator syn match goReceiverVar /\w\+\ze\s\+\%(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl syn match goFunction /\w\+/ nextgroup=goSimpleParams contained skipwhite skipnl - syn match goReceiverType /\w\+/ contained + syn match goReceiverType /\w\+\ze\s*)/ contained if go#config#HighlightFunctionParameters() syn match goSimpleParams /(\%(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType nextgroup=goFunctionReturn skipwhite skipnl syn match goFunctionReturn /(\%(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType skipwhite skipnl @@ -290,7 +294,7 @@ if go#config#HighlightFunctions() || go#config#HighlightFunctionParameters() hi def link goReceiverVar goParamName hi def link goParamName Identifier endif - syn match goReceiver /(\s*\w\+\%(\s\+\*\?\s*\w\+\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl + syn match goReceiver /(\s*\%(\w\+\s\+\)\?\*\?\s*\w\+\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverDecl skipwhite skipnl else syn keyword goDeclaration func endif @@ -351,7 +355,7 @@ endif " Build Constraints if go#config#HighlightBuildConstraints() - syn match goBuildKeyword display contained "+build" + syn match goBuildKeyword display contained "+build\|go:build" " Highlight the known values of GOOS, GOARCH, and other +build options. syn keyword goBuildDirectives contained \ android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 @@ -365,7 +369,7 @@ if go#config#HighlightBuildConstraints() " The rs=s+2 option lets the \s*+build portion be part of the inner region " instead of the matchgroup so it will be highlighted as a goBuildKeyword. syn region goBuildComment matchgroup=goBuildCommentStart - \ start="//\s*+build\s"rs=s+2 end="$" + \ start="//\(\s*+build\s\|go:build\)"rs=s+2 end="$" \ contains=goBuildKeyword,goBuildDirectives hi def link goBuildCommentStart Comment hi def link goBuildDirectives Type |