|
@@ -16,15 +16,15 @@ if g:go_highlight_functions != 0
|
|
|
syn clear goFunction
|
|
syn clear goFunction
|
|
|
|
|
|
|
|
syn match goDeclaration /\<func\>/ nextgroup=goReceiverRegion,goFunction skipwhite skipnl
|
|
syn match goDeclaration /\<func\>/ nextgroup=goReceiverRegion,goFunction skipwhite skipnl
|
|
|
- syn region goReceiverRegion matchgroup=ContainerChars start=/(/ end=/)/ contains=goReceiver nextgroup=goFunction contained
|
|
|
|
|
|
|
+ syn region goReceiverRegion matchgroup=goContainer start=/(/ end=/)/ contains=goReceiver nextgroup=goFunction contained
|
|
|
syn match goReceiver /\(\w\|[ *]\)\+/ contained contains=goReceiverVar skipwhite skipnl contained
|
|
syn match goReceiver /\(\w\|[ *]\)\+/ contained contains=goReceiverVar skipwhite skipnl contained
|
|
|
|
|
|
|
|
- syn cluster validFuncRegionContains contains=@goTypes,goField,goDeclaration,GoBuiltins,goDeclStruct,goDeclInterface,OperatorChars,ContainerChars,goString,goRawString,@goNumber,goTypeConstructor
|
|
|
|
|
|
|
+ syn cluster validFuncRegionContains contains=@goTypes,goField,goDeclaration,GoBuiltins,goDeclStruct,goDeclInterface,OperatorChars,goContainer,goString,goRawString,@goNumber,goTypeConstructor
|
|
|
|
|
|
|
|
" fix comment
|
|
" fix comment
|
|
|
- syn match goFunctionTagLine /\w\+(.\{-})\(\s*(.\{-})\|\s\S\+\)\?\(\s*\|$\)/ nextgroup=goFunction contains=goFunction,goFunctionParamRegion,goFunctionReturnRegion,goFunctionReturn,OperatorChars,ContainerChars,goComment
|
|
|
|
|
- syn region goFunctionParamRegion matchgroup=ContainerChars start=/(/ end=/)/ contains=@validFuncRegionContains nextgroup=goFunctionReturnRegion,goFunctionReturn skipwhite contained
|
|
|
|
|
- syn region goFunctionReturnRegion matchgroup=ContainerChars start=/(/ end=/)/ contains=@validFuncRegionContains skipwhite contained
|
|
|
|
|
|
|
+ syn match goFunctionTagLine /\w\+(.\{-})\(\s*(.\{-})\|\s\S\+\)\?\(\s*\|$\)/ nextgroup=goFunction contains=goFunction,goFunctionParamRegion,goFunctionReturnRegion,goFunctionReturn,OperatorChars,goContainer,goComment
|
|
|
|
|
+ syn region goFunctionParamRegion matchgroup=goContainer start=/(/ end=/)/ contains=@validFuncRegionContains nextgroup=goFunctionReturnRegion,goFunctionReturn skipwhite contained
|
|
|
|
|
+ syn region goFunctionReturnRegion matchgroup=goContainer start=/(/ end=/)/ contains=@validFuncRegionContains skipwhite contained
|
|
|
syn match goFunctionReturn /\w\+/ contains=@validFuncRegionContains skipwhite contained
|
|
syn match goFunctionReturn /\w\+/ contains=@validFuncRegionContains skipwhite contained
|
|
|
syn match goFunction /\w\+\ze(/ nextgroup=goFunctionParamRegion skipwhite contained
|
|
syn match goFunction /\w\+\ze(/ nextgroup=goFunctionParamRegion skipwhite contained
|
|
|
endif
|
|
endif
|
|
@@ -33,29 +33,31 @@ if !exists("g:go_highlight_types")
|
|
|
let g:go_highlight_types = 0
|
|
let g:go_highlight_types = 0
|
|
|
endif
|
|
endif
|
|
|
if g:go_highlight_types != 0
|
|
if g:go_highlight_types != 0
|
|
|
- syn match goTypeConstructor /\<\w\+{/he=e-1 contains=goTypeOpen
|
|
|
|
|
- syn match goTypeOpen /{/ contained
|
|
|
|
|
- "syn match goTypeClose /}/ contained
|
|
|
|
|
|
|
+ syn match goTypeConstructor /\<\w\+\({\)\@1=/
|
|
|
|
|
|
|
|
- " TODO (maybe): handle only Type-highlighting things like xml.Name ignoring
|
|
|
|
|
|
|
+ " TODO (maybe):
|
|
|
|
|
+ " handle only Type-highlighting things like xml.Name ignoring
|
|
|
" the first \w+\. and highlighting the remaining \w+
|
|
" the first \w+\. and highlighting the remaining \w+
|
|
|
"
|
|
"
|
|
|
|
|
+ " handle map[type]type
|
|
|
|
|
+ " handle field, field type
|
|
|
|
|
+
|
|
|
" This is most likely bad... probably very bad.. and brittle?
|
|
" This is most likely bad... probably very bad.. and brittle?
|
|
|
syn clear goTypeDecl
|
|
syn clear goTypeDecl
|
|
|
syn clear goTypeName
|
|
syn clear goTypeName
|
|
|
syn clear goDeclType
|
|
syn clear goDeclType
|
|
|
|
|
|
|
|
- syn cluster validTypeContains contains=goComment,goNewDeclType,goDeclTypeField,goDeclTypeFieldType,goDeclTypeFieldSlice,goDeclTypeFieldPointerOp,goString,goRawString,OperatorChars,ContainerChars
|
|
|
|
|
- syn cluster validStructContains contains=goComment,goNewDeclType,goDeclTypeField,goDeclTypeFieldType,goString,goRawString,OperatorChars,ContainerChars
|
|
|
|
|
- syn cluster validInterfaceContains contains=goComment,goFunctionTagLine,OperatorChars,ContainerChars
|
|
|
|
|
|
|
+ syn cluster validTypeContains contains=goComment,goNewDeclType,goDeclTypeField,goDeclTypeFieldType,goDeclTypeFieldSlice,goDeclTypeFieldPointerOp,goString,goRawString,OperatorChars,goContainer
|
|
|
|
|
+ syn cluster validStructContains contains=goComment,goNewDeclType,goDeclTypeField,goDeclTypeFieldType,goString,goRawString,OperatorChars,goContainer
|
|
|
|
|
+ syn cluster validInterfaceContains contains=goComment,goFunctionTagLine,OperatorChars,goContainer
|
|
|
|
|
|
|
|
syn match goTypeDecl /\<type\>/ nextgroup=goNewDeclType,goTypeRegion skipwhite skipnl
|
|
syn match goTypeDecl /\<type\>/ nextgroup=goNewDeclType,goTypeRegion skipwhite skipnl
|
|
|
- syn region goTypeRegion matchgroup=ContainerChars start=/(/ end=/)/ contains=@validTypeContains fold contained
|
|
|
|
|
- syn region goDeclStructRegion matchgroup=ContainerChars start=/{/ end=/}/ contains=@validStructContains fold contained
|
|
|
|
|
- syn region goDeclInterfaceRegion matchgroup=ContainerChars start=/{/ end=/}/ contains=@validInterfaceContains fold contained
|
|
|
|
|
|
|
+ syn region goTypeRegion matchgroup=goContainer start=/(/ end=/)/ contains=@validTypeContains fold contained
|
|
|
|
|
+ syn region goDeclStructRegion matchgroup=goContainer start=/{/ end=/}/ contains=@validStructContains fold contained
|
|
|
|
|
+ syn region goDeclInterfaceRegion matchgroup=goContainer start=/{/ end=/}/ contains=@validInterfaceContains fold contained
|
|
|
|
|
|
|
|
syn match goDeclTypeFieldPointerOp /\*/ nextgroup=goDeclTypeFieldPointerOp,goDeclTypeFieldSlice,goDeclTypeFieldType,goDeclStruct,goDeclInterface skipwhite contained
|
|
syn match goDeclTypeFieldPointerOp /\*/ nextgroup=goDeclTypeFieldPointerOp,goDeclTypeFieldSlice,goDeclTypeFieldType,goDeclStruct,goDeclInterface skipwhite contained
|
|
|
- syn region goDeclTypeFieldSlice matchgroup=ContainerChars start=/\[/ end=/\]/ contains=goDecimalInt,goHexadecimalInt,goOctalInt nextgroup=goDeclTypeFieldPointerOp,goDeclTypeFieldSlice,goDeclTypeFieldType,goDeclStruct,goDeclInterface skipwhite contained
|
|
|
|
|
|
|
+ syn region goDeclTypeFieldSlice matchgroup=goContainer start=/\[/ end=/\]/ contains=goDecimalInt,goHexadecimalInt,goOctalInt nextgroup=goDeclTypeFieldPointerOp,goDeclTypeFieldSlice,goDeclTypeFieldType,goDeclStruct,goDeclInterface skipwhite contained
|
|
|
syn match goDeclTypeFieldType /\(\w\|\.\)\+/ skipwhite contained
|
|
syn match goDeclTypeFieldType /\(\w\|\.\)\+/ skipwhite contained
|
|
|
syn match goDeclTypeField /\w\+/ nextgroup=goDeclTypeFieldPointerOp,goDeclTypeFieldSlice,goDeclTypeFieldType skipwhite contained
|
|
syn match goDeclTypeField /\w\+/ nextgroup=goDeclTypeFieldPointerOp,goDeclTypeFieldSlice,goDeclTypeFieldType skipwhite contained
|
|
|
syn match goNewDeclType /\w\+\ze\s\+\<\(struct\|interface\)\>/ nextgroup=goDeclStruct,goDeclInterface skipwhite contained
|
|
syn match goNewDeclType /\w\+\ze\s\+\<\(struct\|interface\)\>/ nextgroup=goDeclStruct,goDeclInterface skipwhite contained
|
|
@@ -64,11 +66,15 @@ if g:go_highlight_types != 0
|
|
|
syn match goDeclInterface /\<interface\>/ nextgroup=goDeclInterfaceRegion skipwhite skipnl
|
|
syn match goDeclInterface /\<interface\>/ nextgroup=goDeclInterfaceRegion skipwhite skipnl
|
|
|
endif
|
|
endif
|
|
|
|
|
|
|
|
|
|
+" Order is important, so redefine
|
|
|
|
|
+syn match goBuiltins /\<\v(append|cap|close|complex|copy|delete|imag|len)\ze\(/
|
|
|
|
|
+syn match goBuiltins /\<\v(make|new|panic|print|println|real|recover)\ze\(/
|
|
|
|
|
+
|
|
|
hi link goPointerOperator Operator
|
|
hi link goPointerOperator Operator
|
|
|
hi link goDeclTypeFieldPointerOp Operator
|
|
hi link goDeclTypeFieldPointerOp Operator
|
|
|
|
|
|
|
|
hi link goTypeConstructor Type
|
|
hi link goTypeConstructor Type
|
|
|
-hi link goTypeOpen ContainerChars
|
|
|
|
|
|
|
+hi link goTypeOpen goContainer
|
|
|
|
|
|
|
|
hi link goDeclTypeFieldType Type
|
|
hi link goDeclTypeFieldType Type
|
|
|
hi link goNewDeclType Type
|
|
hi link goNewDeclType Type
|
|
@@ -79,3 +85,5 @@ hi link goDeclStruct Keyword
|
|
|
hi link goFunction Function
|
|
hi link goFunction Function
|
|
|
hi link goMethodCall Function
|
|
hi link goMethodCall Function
|
|
|
hi link goFunctionCall Function
|
|
hi link goFunctionCall Function
|
|
|
|
|
+
|
|
|
|
|
+hi link goContainer ContainerChars
|