@@ -397,44 +397,44 @@ syntax match goPointer /*/ contained nextgroup=@goType
397397
398398" goTypeParens is used to ensure types within parens are highlighted correctly,
399399" e.g. the func type in the slice literal `[](func (a, b int) bool){ ... }`
400- syntax region goTypeParens start =' (' end =' )' contained contains =@goType
400+ syntax region goTypeParens start =' (' end =' )' contained contains =@goType,goComment
401401
402402syntax keyword goTypeDecl type skipwhite skipempty nextgroup =goTypeDeclName,goTypeDeclGroup
403403syntax match goTypeDeclName / \K\k */ contained skipwhite skipempty nextgroup =goTypeDeclTypeParams,goTypeAssign,@goType
404404syntax match goTypeAssign / =/ contained skipwhite nextgroup =@goType
405405
406406syntax region goTypeDeclGroup matchgroup =goTypeDeclGroupParens start =' (' end =' )' contained contains =goTypeDeclName,goComment
407- syntax region goTypeDeclTypeParams matchgroup =goTypeParamBrackets start =' \[ ' end =' \] ' contained contains =goTypeParam,goComma nextgroup =@goType
407+ syntax region goTypeDeclTypeParams matchgroup =goTypeParamBrackets start =' \[ ' end =' \] ' contained contains =goTypeParam,goComma,goComment nextgroup =@goType
408408
409409" goNonPrimitiveType is used for matching the names and packages of
410410" non-primitive types (i.e. types other than int, bool, string, etc.). Note the
411411" optional non-capturing group is later in the pattern to avoid backtracking.
412412syntax match goNonPrimitiveType / \<\K\k *\% (\.\K\k *\)\?\[\? / contained contains =goPackageName,goTypeArgs
413413syntax match goPackageName / \<\K\k *\z e\. / contained nextgroup =goDot
414414
415- syntax region goTypeArgs matchgroup =goTypeParamBrackets start =' \[ ' end =' \] ' contained contains =@goType,goUnderscore,goComma
415+ syntax region goTypeArgs matchgroup =goTypeParamBrackets start =' \[ ' end =' \] ' contained contains =@goType,goUnderscore,goComma,goComment
416416
417417syntax keyword goPrimitiveTypes any bool byte complex128 complex64 error float32 float64 int int8 int16 int32 int64 rune string uint uint8 uint16 uint32 uint64 uintptr contained
418418
419419syntax match goFuncType / func\s *(/ contained contains =goFuncTypeParens skipwhite nextgroup =@goType,goFuncTypeMultiReturnType
420420
421- syntax region goFuncTypeParens matchgroup =goFuncParens start =' (' end =' )' contained contains =goFuncTypeParam,goComma
422- syntax region goFuncTypeMultiReturnType matchgroup =goFuncMultiReturnParens start =' (' end =' )' contained contains =goNamedReturnValue,goComma
421+ syntax region goFuncTypeParens matchgroup =goFuncParens start =' (' end =' )' contained contains =goFuncTypeParam,goComma,goComment
422+ syntax region goFuncTypeMultiReturnType matchgroup =goFuncMultiReturnParens start =' (' end =' )' contained contains =goNamedReturnValue,goComma,goComment
423423
424424syntax keyword goMap map contained skipwhite skipempty nextgroup =goMapKeyType
425425syntax region goMapKeyType matchgroup =goMapBrackets start =' \[ ' end =' \] ' contained contains =@goType skipwhite nextgroup =@goType
426426
427427syntax match goSliceOrArrayType / \[\% (\d\+\|\.\.\.\)\?\] / contained contains =goNumber,goDot skipwhite nextgroup =@goType
428428
429429" A lookbehind is used to distinguish a slice/array literal with slice indexing
430- syntax match goSliceOrArrayLiteral / \k\@ 1<!\[\% ( \d\+\|\.\.\.\)\? \]\z e\% (\*\|\K\|\[\| (\) / contained contains =goNumber,goDot skipwhite nextgroup =goSliceItemType
430+ syntax match goSliceOrArrayLiteral / \k\@ 1<!\[ [0-9.]* \]\z e\% (\*\|\K\|\[\| (\) / contained contains =goNumber,goDot skipwhite nextgroup =goSliceItemType
431431
432432" Only look to the end of the line for the item type, and let slices etc. extend
433433" across lines as necessary. Note the first '(' is to match the first paren
434434" around the type, which is then extended by goTypeParens.
435435syntax match goSliceItemType / (\|\% (\% (interface\| struct\)\s *{\| [^{()]\)\+ / contained contains =@goType skipwhite nextgroup =goSliceItems
436436
437- syntax region goSliceItems matchgroup =goSliceBraces start =' {' end =' }' contained contains =goStructLiteralBlock,@goExpr
437+ syntax region goSliceItems matchgroup =goSliceBraces start =' {' end =' }' contained contains =goStructLiteralBlock,@goExpr,goComment
438438
439439syntax match goChannel / <-chan/ contained contains =goChannelDir skipwhite nextgroup =@goType
440440syntax match goChannel / chan\% (<-\)\? / contained contains =goChannelDir skipwhite nextgroup =@goType
@@ -476,8 +476,8 @@ call s:HiConfig('goMapBrackets', ['go_highlight_map_brackets'])
476476
477477" Unfortunately limited to at most 3 nested type args
478478syntax match goFuncCall / \v\K\k *\z e%(\( |\[\s *\n ?%(,\n |[^\[\] ]|\[\s *\n ?%(,\n |[^\[\] ]|\[ [^\[\] ]*\] )*\] )*\]\( )/ contained nextgroup =goFuncCallTypeArgs,goFuncCallArgs
479- syntax region goFuncCallTypeArgs matchgroup =goTypeParamBrackets start =' \[ ' end =' \] ' contained contains =@goType,goUnderscore,goComma nextgroup =goFuncCallArgs
480- syntax region goFuncCallArgs matchgroup =goFuncCallParens start =' (' end =' )' contained contains =@goExpr
479+ syntax region goFuncCallTypeArgs matchgroup =goTypeParamBrackets start =' \[ ' end =' \] ' contained contains =@goType,goUnderscore,goComma,goComment nextgroup =goFuncCallArgs
480+ syntax region goFuncCallArgs matchgroup =goFuncCallParens start =' (' end =' )' contained contains =@goExpr,goComment
481481
482482syntax keyword goFuncDecl func skipwhite skipempty nextgroup =goFuncName,goMethodReceiver
483483syntax keyword goFuncLiteral func contained skipwhite skipempty nextgroup =goFuncName,goFuncParams
@@ -491,7 +491,7 @@ syntax match goParamComma /,/ contained skipwhite skipempty nextgroup=goPara
491491
492492syntax match goFuncName / \K\k */ contained skipwhite nextgroup =goFuncTypeParams,goFuncParams
493493
494- syntax region goFuncTypeParams matchgroup =goTypeParamBrackets start =' \[ ' end =' \] ' contained contains =goTypeParam,goComma nextgroup =goFuncParams
494+ syntax region goFuncTypeParams matchgroup =goTypeParamBrackets start =' \[ ' end =' \] ' contained contains =goTypeParam,goComma,goComment nextgroup =goFuncParams
495495
496496" TODO: is skipempty needed?
497497syntax match goTypeParam / \K\k */ contained skipwhite skipempty nextgroup =goTypeParamComma,goTypeConstraint
@@ -505,9 +505,9 @@ syntax match goTypeConstraintSymbols /[~|]/ contained
505505
506506syntax match goFuncReturnType / \s *\z s(\@ 1<!\% (\% (interface\| struct\)\s *{\| [^{]\)\+ {\@ 1<!/ contained contains =@goType skipwhite skipempty nextgroup =goFuncBlock
507507
508- syntax region goFuncParams matchgroup =goFuncParens start =' (' end =' )' contained contains =goParam,goComma skipwhite nextgroup =goFuncReturnType,goFuncMultiReturn,goFuncBlock
509- syntax region goFuncMultiReturn matchgroup =goFuncMultiReturnParens start =' (' end =' )' contained contains =goNamedReturnValue,goComma skipwhite skipempty nextgroup =goFuncBlock
510- syntax region goMethodReceiver matchgroup =goReceiverParens start =' (' end =' )' contained contains =goFuncTypeParam skipwhite skipempty nextgroup =goFuncName
508+ syntax region goFuncParams matchgroup =goFuncParens start =' (' end =' )' contained contains =goParam,goComma,goComment skipwhite nextgroup =goFuncReturnType,goFuncMultiReturn,goFuncBlock
509+ syntax region goFuncMultiReturn matchgroup =goFuncMultiReturnParens start =' (' end =' )' contained contains =goNamedReturnValue,goComma,goComment skipwhite skipempty nextgroup =goFuncBlock
510+ syntax region goMethodReceiver matchgroup =goReceiverParens start =' (' end =' )' contained contains =goFuncTypeParam,goComment skipwhite skipempty nextgroup =goFuncName
511511
512512GoFoldFunc syntax region goFuncBlock matchgroup= goFuncBraces start = ' {' end = ' }' contained contains= @g oStatement skipwhite nextgroup= goFuncCallArgs
513513
@@ -567,19 +567,19 @@ syntax match goEmbeddedType /\*\?\K\k*\%(\.\K\k*\)\?\%#\@1<!$/ containe
567567" It is technically possible to have a space between a struct name and the
568568" braces, but it's hard to reliably highlight
569569syntax match goStructLiteral / \v\K\k *\z e%(\{ |\[\s *\n ?%(,\n |[^\[\] ]|\[\s *\n ?%(,\n |[^\[\] ]|\[ [^\[\] ]*\] )*\] )*\]\{ )/ contained nextgroup =goStructLiteralTypeArgs,goStructLiteralBlock
570- syntax region goStructLiteralTypeArgs matchgroup =goTypeParamBrackets start =' \[ ' end =' \] ' contained contains =@goType,goUnderscore,goComma nextgroup =goStructLiteralBlock
570+ syntax region goStructLiteralTypeArgs matchgroup =goTypeParamBrackets start =' \[ ' end =' \] ' contained contains =@goType,goUnderscore,goComma,goComment nextgroup =goStructLiteralBlock
571571
572- GoFoldStruct syntax region goStructLiteralBlock matchgroup= goStructBraces start = ' {' end = ' }' contained contains= goStructLiteralField,goComma,@g oExpr
572+ GoFoldStruct syntax region goStructLiteralBlock matchgroup= goStructBraces start = ' {' end = ' }' contained contains= goStructLiteralField,goComma,@g oExpr,goComment
573573
574- syntax match goStructLiteralField / \<\K\k *\z e:/ contained nextgroup =goStructLiteralColon
575- syntax match goStructLiteralColon / :/ contained
574+ syntax match goStructLiteralField / \<\K\k *\z e:/ contained nextgroup =goStructLiteralColon
575+ syntax match goStructLiteralColon / :/ contained
576576
577577syntax keyword goInterfaceType interface contained skipwhite skipempty nextgroup =goInterfaceBlock
578578syntax region goInterfaceBlock matchgroup =goInterfaceBraces start =' {' end =' }' contained contains =@goType,goTypeConstraintSymbols,goInterfaceMethod,goComment extend
579579
580580syntax match goInterfaceMethod / \K\k *\z e(/ contained skipwhite nextgroup =goInterfaceMethodParams
581- syntax region goInterfaceMethodParams matchgroup =goInterfaceMethodParens start =' (' end =' )' contained contains =goFuncTypeParam,goComma skipwhite nextgroup =@goType,goInterfaceMethodMultiReturn
582- syntax region goInterfaceMethodMultiReturn matchgroup =goFuncMultiReturnParens start =' (' end =' )' contained contains =goNamedReturnValue,goComma
581+ syntax region goInterfaceMethodParams matchgroup =goInterfaceMethodParens start =' (' end =' )' contained contains =goFuncTypeParam,goComma,goComment skipwhite nextgroup =@goType,goInterfaceMethodMultiReturn
582+ syntax region goInterfaceMethodMultiReturn matchgroup =goFuncMultiReturnParens start =' (' end =' )' contained contains =goNamedReturnValue,goComma,goComment
583583
584584hi link goStructType Keyword
585585hi link goStructTypeBraces goBraces
@@ -609,10 +609,10 @@ call s:HiConfig('goStructTypeField', ['go_highlight_struct_type_fields'], #{d
609609syntax keyword goBuiltins append cap close complex copy delete imag len panic print println real recover contained skipwhite nextgroup =goFuncCallArgs
610610
611611syntax keyword goMakeBuiltin make contained skipwhite nextgroup =goMakeBlock
612- syntax region goMakeBlock matchgroup =goFuncCallParens start =' (' end =' )' contained contains =@goType,@goExpr
612+ syntax region goMakeBlock matchgroup =goFuncCallParens start =' (' end =' )' contained contains =@goType,@goExpr,goComment
613613
614614syntax keyword goNewBuiltin new contained skipwhite nextgroup =goNewBlock
615- syntax region goNewBlock matchgroup =goFuncCallParens start =' (' end =' )' contained contains =@goType
615+ syntax region goNewBlock matchgroup =goFuncCallParens start =' (' end =' )' contained contains =@goType,@goExpr,goComment
616616
617617hi link goBuiltins Special
618618hi link goMakeBuiltin goBuiltins
0 commit comments