Skip to content

Commit 479fba9

Browse files
committed
perf(syntax): simplify @rustIdentifiers
There didn't need to be a huge chain of syntax groups to check. Some of them could be contained in other groups, and this should also help in removing the need to check for reduntant groups until a group which contains those groups is matched.
1 parent e28ea95 commit 479fba9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

syntax/rust.vim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ syn keyword rustExternCrate crate contained nextgroup=rustType,rustExternCrate
6767
syn match rustExternCrateString /".*"\_s*as/ contained display nextgroup=rustType skipwhite transparent skipempty contains=rustString,rustOperator
6868
syn keyword rustObsoleteExternMod mod contained nextgroup=rustType skipempty skipwhite
6969

70-
syn match rustIdentifier "\<\l\+\(_\l\+\)*\((\)\@!\>" contained contains=rustBoolean,rustSelf display
71-
syn match rustType "\<\(\u\l*\)\+\((\)\@!\>" contains=rustTypePrime contained display
72-
syn match rustConstant "\<\u\+\(_\u\+\)*\((\)\@!\>" contained display
73-
syn match rustFuncName "\<\w\+\(::\)\?\(<.*>\)\?\s*\((\)\@=\>" contains=rustEnumVariant,rustModPathSep,rustGenericRegion display
74-
syn cluster rustIdentifiers contains=@rustLifetimes,rustModPath,rustBuiltinType,rustEnum,rustTrait,rustEnumVariant,rustMacro,rustFuncName,rustConstant,rustIdentifier,rustType
70+
syn match rustIdentifier "\<\l\+\(_\+\l\+\)*\>" contained contains=rustBoolean,rustSelf display
71+
syn match rustConstant "\<\u\+\(_\+\u\+\)*\>" contained display
72+
syn match rustFuncName "\<\w\+\(::\)\?\(<.*>\)\?\s*\((\)\@=\>" contains=rustModPathSep,rustGenericRegion display
73+
syn match rustType "\<\(\u\l*\)\+\>" contains=rustEnum,rustEnumVariant,rustTrait display
74+
syn cluster rustIdentifiers contains=@rustLifetimes,rustModPath,rustMacro,rustBuiltinType,rustType,rustFuncName,rustConstant,rustIdentifier
7575

7676
syn region rustMacroRepeat matchgroup=rustMacroRepeatDelimiters start="$(" end="),\=[*+]" contains=TOP
7777
syn match rustMacroVariable "\$\w\+" display

0 commit comments

Comments
 (0)