From 8500ae8bb9f4da69273eace4d9cef54ae7f18627 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Mon, 6 Jul 2020 19:13:39 +0200 Subject: Update --- syntax/crystal.vim | 96 +++++++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 45 deletions(-) (limited to 'syntax/crystal.vim') diff --git a/syntax/crystal.vim b/syntax/crystal.vim index 217cb6db..c3ed4c18 100644 --- a/syntax/crystal.vim +++ b/syntax/crystal.vim @@ -150,6 +150,7 @@ syn match crystalModuleName "\%(\%([.@$]\@1\|::\)\@=" contained syn match crystalLibName "\%(\%([.@$]\@1\|::\)\@=" contained syn match crystalEnumName "\%(\%([.@$]\@1\|::\)\@=" contained +syn match crystalAnnotationName "\%(\%([.@$]\@1\|::\)\@=" contained syn match crystalConstant "\%(\%([.@$]\@1\|::\)\@=" syn match crystalClassVariable "@@\%(\h\|%\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*" display syn match crystalInstanceVariable "@\%(\h\|%\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*" display @@ -247,53 +248,56 @@ SynFold '<<' syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\ SynFold '<<' syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=crystalAliasDeclaration,crystalAliasDeclaration2,crystalMethodDeclaration,crystalFunctionDeclaration -syn cluster crystalDeclaration contains=crystalAliasDeclaration,crystalAliasDeclaration2,crystalMethodDeclaration,crystalFunctionDeclaration,crystalModuleDeclaration,crystalClassDeclaration,crystalStructDeclaration,crystalLibDeclaration,crystalMacroDeclaration,crystalFunction,crystalBlockParameter,crystalTypeDeclaration,crystalEnumDeclaration +syn cluster crystalDeclaration contains=crystalAliasDeclaration,crystalAliasDeclaration2,crystalMethodDeclaration,crystalFunctionDeclaration,crystalModuleDeclaration,crystalClassDeclaration,crystalStructDeclaration,crystalLibDeclaration,crystalMacroDeclaration,crystalFunction,crystalBlockParameter,crystalTypeDeclaration,crystalEnumDeclaration,crystalAnnotationDeclaration " Keywords " Note: the following keywords have already been defined: " begin case class def do end for if module unless until while syn match crystalControl "\<\%(break\|next\|rescue\|return\)\>[?!]\@!" -syn match crystalOperator "\[?!]\@!" syn match crystalBoolean "\<\%(true\|false\)\>[?!]\@!" -syn match crystalPseudoVariable "\<\%(nil\|self\|__DIR__\|__FILE__\|__LINE__\|__END_LINE__\)\>[?!]\@!" " TODO: reorganise +syn match crystalPseudoVariable "\<\%(nil\|__DIR__\|__FILE__\|__LINE__\|__END_LINE__\)\>[?!]\@!" " TODO: reorganise +syn match crystalPseudoVariable "\" " Expensive Mode - match 'end' with the appropriate opening keyword for syntax " based folding and special highlighting of module/class/method definitions if !exists('b:crystal_no_expensive') && !exists('g:crystal_no_expensive') - syn match crystalDefine "\" nextgroup=crystalAliasDeclaration skipwhite skipnl - syn match crystalDefine "\" nextgroup=crystalMethodDeclaration skipwhite skipnl - syn match crystalDefine "\" nextgroup=crystalFunctionDeclaration skipwhite skipnl - syn match crystalDefine "\" nextgroup=crystalFunction skipwhite skipnl - syn match crystalDefine "\<\%(type\|alias\)\>\%(\s*\h\w*\s*=\)\@=" nextgroup=crystalTypeDeclaration skipwhite skipnl - syn match crystalClass "\" nextgroup=crystalClassDeclaration skipwhite skipnl - syn match crystalModule "\" nextgroup=crystalModuleDeclaration skipwhite skipnl - syn match crystalStruct "\" nextgroup=crystalStructDeclaration skipwhite skipnl - syn match crystalLib "\" nextgroup=crystalLibDeclaration skipwhite skipnl - syn match crystalMacro "\" nextgroup=crystalMacroDeclaration skipwhite skipnl - syn match crystalEnum "\" nextgroup=crystalEnumDeclaration skipwhite skipnl - - SynFold 'def' syn region crystalMethodBlock start="\<\%(def\|macro\)\>" matchgroup=crystalDefine end="\%(\<\%(def\|macro\)\_s\+\)\@" contains=TOP - SynFold 'class' syn region crystalBlock start="\" matchgroup=crystalClass end="\" contains=TOP - SynFold 'module' syn region crystalBlock start="\" matchgroup=crystalModule end="\" contains=TOP - SynFold 'struct' syn region crystalBlock start="\" matchgroup=crystalStruct end="\" contains=TOP - SynFold 'lib' syn region crystalBlock start="\" matchgroup=crystalLib end="\" contains=TOP - SynFold 'enum' syn region crystalBlock start="\" matchgroup=crystalEnum end="\" contains=TOP + syn match crystalDefine "\" nextgroup=crystalAliasDeclaration skipwhite skipnl + syn match crystalDefine "\" nextgroup=crystalMethodDeclaration skipwhite skipnl + syn match crystalDefine "\" nextgroup=crystalFunctionDeclaration skipwhite skipnl + syn match crystalDefine "\" nextgroup=crystalFunction skipwhite skipnl + syn match crystalDefine "\<\%(type\|alias\)\>\%(\s*\h\w*\s*=\)\@=" nextgroup=crystalTypeDeclaration skipwhite skipnl + syn match crystalClass "\" nextgroup=crystalClassDeclaration skipwhite skipnl + syn match crystalModule "\" nextgroup=crystalModuleDeclaration skipwhite skipnl + syn match crystalStruct "\" nextgroup=crystalStructDeclaration skipwhite skipnl + syn match crystalLib "\" nextgroup=crystalLibDeclaration skipwhite skipnl + syn match crystalMacro "\" nextgroup=crystalMacroDeclaration skipwhite skipnl + syn match crystalEnum "\" nextgroup=crystalEnumDeclaration skipwhite skipnl + syn match crystalAnnotation "\" nextgroup=crystalAnnotationDeclaration skipwhite skipnl + + SynFold 'def' syn region crystalMethodBlock start="\<\%(def\|macro\)\>" matchgroup=crystalDefine end="\%(\<\%(def\|macro\)\_s\+\)\@" contains=TOP + SynFold 'class' syn region crystalBlock start="\" matchgroup=crystalClass end="\" contains=TOP + SynFold 'module' syn region crystalBlock start="\" matchgroup=crystalModule end="\" contains=TOP + SynFold 'struct' syn region crystalBlock start="\" matchgroup=crystalStruct end="\" contains=TOP + SynFold 'lib' syn region crystalBlock start="\" matchgroup=crystalLib end="\" contains=TOP + SynFold 'enum' syn region crystalBlock start="\" matchgroup=crystalEnum end="\" contains=TOP + SynFold 'annotation' syn region crystalBlock start="\" matchgroup=crystalAnnotation end="\" contains=TOP " modifiers syn match crystalConditionalModifier "\<\%(if\|unless\|ifdef\)\>" display @@ -326,14 +330,15 @@ if !exists('b:crystal_no_expensive') && !exists('g:crystal_no_expensive') exec 'syn sync minlines=' . g:crystal_minlines else " Non-expensive mode - syn match crystalControl "\[?!]\@!" nextgroup=crystalMethodDeclaration skipwhite skipnl - syn match crystalControl "\[?!]\@!" nextgroup=crystalFunctionDeclaration skipwhite skipnl - syn match crystalControl "\[?!]\@!" nextgroup=crystalClassDeclaration skipwhite skipnl - syn match crystalControl "\[?!]\@!" nextgroup=crystalModuleDeclaration skipwhite skipnl - syn match crystalControl "\[?!]\@!" nextgroup=crystalStructDeclaration skipwhite skipnl - syn match crystalControl "\[?!]\@!" nextgroup=crystalLibDeclaration skipwhite skipnl - syn match crystalControl "\[?!]\@!" nextgroup=crystalMacroDeclaration skipwhite skipnl - syn match crystalControl "\[?!]\@!" nextgroup=crystalEnumDeclaration skipwhite skipnl + syn match crystalControl "\[?!]\@!" nextgroup=crystalMethodDeclaration skipwhite skipnl + syn match crystalControl "\[?!]\@!" nextgroup=crystalFunctionDeclaration skipwhite skipnl + syn match crystalControl "\[?!]\@!" nextgroup=crystalClassDeclaration skipwhite skipnl + syn match crystalControl "\[?!]\@!" nextgroup=crystalModuleDeclaration skipwhite skipnl + syn match crystalControl "\[?!]\@!" nextgroup=crystalStructDeclaration skipwhite skipnl + syn match crystalControl "\[?!]\@!" nextgroup=crystalLibDeclaration skipwhite skipnl + syn match crystalControl "\[?!]\@!" nextgroup=crystalMacroDeclaration skipwhite skipnl + syn match crystalControl "\[?!]\@!" nextgroup=crystalEnumDeclaration skipwhite skipnl + syn match crystalControl "\[?!]\@!" nextgroup=crystalAnnotationDeclaration skipwhite skipnl syn match crystalControl "\<\%(case\|begin\|do\|if\|ifdef\|unless\|while\|until\|else\|elsif\|ensure\|then\|when\|end\)\>[?!]\@!" syn match crystalKeyword "\<\%(alias\|undef\)\>[?!]\@!" endif @@ -358,8 +363,8 @@ endif " Macro " Note: This definition must be put after crystalNestedCurlyBraces to give higher priority -syn region crystalMacroRegion matchgroup=crystalMacroDelim start="\\\={%" end="%}" oneline display contains=@crystalMacroGroup containedin=ALL -syn region crystalMacroRegion matchgroup=crystalMacroDelim start="\\\={{" end="}}" oneline display contains=@crystalMacroGroup containedin=ALL +syn region crystalMacroRegion matchgroup=crystalMacroDelim start="\\\={%" end="%}" display oneline contains=@crystalMacroGroup containedin=ALL +syn region crystalMacroRegion matchgroup=crystalMacroDelim start="\\\={{" end="}}" display contains=TOP containedin=ALL " Cluster for groups that can appear inside macro expressions syn cluster crystalMacroGroup contains=@crystalTop @@ -375,8 +380,7 @@ syn cluster crystalMacroGroup remove=@crystalExpensive " Some keywords will have to be redefined for them to be highlighted " properly syn keyword crystalMacroKeyword contained - \ if else elsif end for in begin do case when while until loop - \ rescue ensure + \ if unless else elsif end for in do while until loop begin syn cluster crystalMacroGroup add=crystalMacroKeyword @@ -414,6 +418,7 @@ hi def link crystalModule crystalDefine hi def link crystalStruct crystalDefine hi def link crystalLib crystalDefine hi def link crystalEnum crystalDefine +hi def link crystalAnnotation crystalDefine hi def link crystalMethodExceptional crystalDefine hi def link crystalDefine Define hi def link crystalFunction Function @@ -442,6 +447,7 @@ hi def link crystalModuleName crystalConstant hi def link crystalStructName crystalConstant hi def link crystalLibName crystalConstant hi def link crystalEnumName crystalConstant +hi def link crystalAnnotationName crystalConstant hi def link crystalGlobalVariable crystalIdentifier hi def link crystalBlockParameter crystalIdentifier hi def link crystalInstanceVariable crystalIdentifier @@ -478,7 +484,7 @@ hi def link crystalRegexp crystalString hi def link crystalMacro PreProc hi def link crystalMacroDelim crystalMacro hi def link crystalMacroKeyword crystalKeyword -hi def link crystalLinkAttrDelim crystalMacro +hi def link crystalLinkAttrDelim crystalMacroDelim hi def link crystalError Error hi def link crystalInvalidVariable crystalError hi def link crystalSpaceError crystalError -- cgit v1.2.3