| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- if !exists("g:go_highlight_fields")
- let g:go_highlight_fields = 0
- endif
- if g:go_highlight_fields != 0
- syn match goField /\(\.\)\@1<=\w\+\([.\ \n\r\:\)\[,+-\*}\\\]]\)\@=/
- endif
- " Order matters...
- if !exists("g:go_highlight_functions")
- let g:go_highlight_functions = 0
- endif
- if g:go_highlight_functions != 0
- " FIXME: This is too greedy
- syn match listOfTypes /\([^ ,)]\+\(,\|)\)\@=\)\+/ contains=@goDeclarations,@goDeclTypeBegin,goMapKeyRegion,goFunctionParamRegion,goFunctionReturnRegion,goDeclStructRegion,goDeclInterfaceRegion contained
- syn match listOfVars /\([,(]\s*\)\@<=\w\+\(\(, \w\+\)*, \w\+ \)\@=/ contained
- endif
- if !exists("g:go_highlight_types")
- let g:go_highlight_types = 0
- endif
- if g:go_highlight_types != 0
- syn clear goTypeDecl
- syn clear goTypeName
- syn clear goDeclType
- syn match goTypeConstructor /\<\w\+\({\)\@1=/
- syn cluster validTypeContains contains=goComment,goDeclSIName,goDeclTypeField,goDeclTypeName
- " FIXME: not sure I _need_ to state goDecl_Region
- syn cluster validStructContains contains=goComment,goDeclSIName,goDeclTypeField,goDeclTypeSep,goDeclEmbeddedStructType,goString,goRawString,goMapType,goMapKeyRegion,goDeclStructRegion,goDeclInterfaceRegion,goPointerOperator
- syn cluster validInterfaceContains contains=goComment,goFunction,goEmbeddedInterfaceType
- syn match goDeclTypeField /\w\+/ nextgroup=goDeclTypeSep,@goDeclTypeBegin skipwhite contained
- syn match goDeclTypeSep /,/ nextgroup=goDeclTypeField skipwhite contained
- syn match goDeclEmbeddedStructType /\w\+\s*\($\|\/\)\@=/ skipwhite contained
- syn match goDeclTypeName /\w\+/ nextgroup=@goDeclTypeBegin skipwhite contained
- syn match goTypeDecl /\<type\>/ nextgroup=goDeclTypeName,goTypeRegion skipwhite skipnl
- syn region goTypeRegion matchgroup=goContainer start=/(/ end=/)/ contains=@validTypeContains skipwhite fold contained
- syn region goDeclStructRegion matchgroup=goContainer start=/{/ end=/}/ contains=@validStructContains skipwhite fold contained
- syn region goDeclInterfaceRegion matchgroup=goContainer start=/{/ end=/}/ contains=@validInterfaceContains skipwhite fold contained
- syn match goEmbeddedInterfaceType /\w\+/ contained
- syn match goDeclTypeStart /\*/ contains=OperatorChars nextgroup=goDeclTypeStart,goDeclTypeNamespace,goDeclTypeType,goMapType,@goDeclarations skipwhite contained
- syn region goDeclTypeStart matchgroup=goContainer start=/\[/ end=/\]/ contains=@goNumbers nextgroup=goDeclTypeStart,goDeclTypeNamespace,goDeclTypeType,goMapType,@goDeclarations skipwhite transparent contained
- syn match goDeclTypeType /\w\+/ contains=goMapType,@goDeclarations skipwhite contained
- syn match goDeclTypeNamespace /\w\+\./ contains=OperatorChars nextgroup=goDeclTypeType skipwhite contained
- syn cluster goDeclTypeBegin contains=goDeclTypeStart,goDeclTypeType,goDeclTypeNamespace,goDeclaration,goMapType,goDeclStruct,goDeclInterface
- syn region goMapKeyRegion matchgroup=goContainer start=/\[/ end=/\]/ contains=@goDeclTypeBegin,goDeclaration nextgroup=@goDeclTypeBegin skipwhite contained
- syn keyword goMapType map nextgroup=goMapKeyRegion skipwhite
- " This is important in order to differentiate "field type" from "field struct"
- " and "field interface"
- " FIXME: seems fishy, see @validStructContains
- syn match goDeclSIName /\w\+\(\s\([*\[\] ]\)*\<\(struct\|interface\)\>\)\@=/ nextgroup=@goDeclTypeBegin,goDeclStruct,goDeclInterface skipwhite contained
- syn match goDeclStruct /\<struct\>/ nextgroup=goDeclStructRegion skipwhite skipnl
- syn match goDeclInterface /\<interface\>/ nextgroup=goDeclInterfaceRegion skipwhite skipnl
- syn match goVarName /[^, ]\+/ nextgroup=goVarSep,@goDeclTypeBegin,goMapType skipwhite contained
- syn match goVarSep /,/ nextgroup=goVarName skipwhite contained
- syn region goVarRegion matchgroup=goContainer start=/(/ end=/)/ transparent contained
- syn keyword goVarDecl var nextgroup=goVarName,goVarRegion skipwhite
- syn region goTypeAssertionRegion matchgroup=goContainer start=/(/ end=/)/ contains=@goDeclTypeBegin,goMapType,goMapKeyRegion skipwhite contained
- syn match goTypeAssertionOp /\.\((\)\@=/ nextgroup=goTypeAssertionRegion skipwhite
- endif
- if g:go_highlight_functions != 0
- syn clear goFunctionCall
- syn clear goFunction
- syn clear goReceiverType
- syn match goFunctionCall /\(\.\)\@1<!\w\+\((\)\@1=/ nextgroup=goFuncMethCallRegion
- " FIXME: [^,()] is a lazy hack-fix that works in-tandem with listOfTypes
- syn match goFunctionReturn /[^,()]\{-}\({\|\/\|$\)\@=/ contains=@goDeclarations,@goDeclTypeBegin,goComment skipwhite contained
- syn region goFunctionParamRegion matchgroup=goContainer start=/(/ end=/)/ contains=@goDeclarations,listOfTypes,listOfVars,OperatorChars nextgroup=goFunctionReturn,goFunctionReturnRegion skipwhite transparent contained
- syn region goFunctionReturnRegion matchgroup=goContainer start=/(/ end=/)/ contains=@goDeclarations,listOfTypes,listOfVars,OperatorChars skipwhite transparent contained
- syn match goFunction /\w\+\((\)\@1=/ nextgroup=goFunctionParamRegion skipwhite contained
- syn match goDeclaration /\<func\>/ nextgroup=goReceiverRegion,goFunction,goFunctionParamRegion skipwhite skipnl
- " Use the space between func and ( to determine if the next group is a
- " receiver or an inlined function (which matches gofmt)
- syn region goReceiverRegion matchgroup=goContainer start=/ (/ end=/)/ contains=goReceiverVar,goPointerOperator,@goDeclTypeBegin nextgroup=goFunction skipwhite contained
- syn match goReceiverVar /\w\+ / nextgroup=goPointerOperator,@goDeclTypeBegin skipnl contained
- syn match goPointerOperator /\*/ nextgroup=@goDeclTypeBegin skipwhite skipnl contained
- endif
- if !exists("g:go_highlight_methods")
- let g:go_highlight_methods = 0
- endif
- if g:go_highlight_methods != 0
- syn clear goMethodCall
- syn match goMethodCall /\(\.\)\@1<=\w\+\((\)\@1=/ nextgroup=goFuncMethCallRegion
- endif
- syn cluster goDeclarations contains=goDeclaration,goDeclStruct,goDeclInterface
- syn cluster goTypes contains=goType,goSignedInts,goUnsignedInts,goFloats,goComplexes
- syn cluster goNumbers contains=goDecimalInt,goHexadecimalInt,goOctalInt,goFloat,goImaginary,goImaginaryFloat
- syn region goFuncMethCallRegion matchgroup=goContainer start=/(/ end=/)/ transparent contained
- syn match goLiteralStructField /\w\+\ze:[^=]/
- " Order is important, so redefine
- syn match goBuiltins /\<\(append\|cap\|close\|complex\|copy\|delete\|imag\|len\)\((\)\@=/ nextgroup=goBuiltinRegion
- syn match goBuiltins /\<\(make\|new\|panic\|print\|println\|real\|recover\)\((\)\@=/ nextgroup=goBuiltinRegion
- syn region goBuiltinRegion matchgroup=goContainer start=/(/ end=/)/ transparent contained
- hi link goPointerOperator Operator
- hi link goTypeAssertionOp Operator
- hi link goVarSep Operator
- hi link goDeclTypeSep Operator
- hi link goTypeConstructor Type
- hi link goDeclSIName Type
- hi link goDeclTypeType Type
- hi link goEmbeddedInterfaceType Type
- hi link goMapType Type
- hi link goDeclTypeName Type
- hi link goDeclEmbeddedStructType Type
- hi link goVarDecl goDeclaration
- hi link goDeclInterface goDeclaration
- hi link goDeclStruct goDeclaration
- hi link goFunction Function
- hi link goMethodCall Function
- hi link goFunctionCall Function
- hi link goContainer ContainerChars
- hi link goLiteralStructField Special
|