22" Language: Cangjie
33" Maintainer: Wu Junkai <wu.junkai@qq.com>
44" URL: https://github.com/WuJunkai2004/cangjie.vim
5- " Last Change: 2025 Oct 12
5+ " Last Change: 2026 Jan 5
66"
77" The Cangjie programming language is a new-generation programming
88" language oriented to full-scenario intelligence. It features
@@ -33,9 +33,13 @@ endfunction
3333syn case match
3434
3535" 1. comments
36- syn keyword cangjieTodo TODO FIXME XXX NOTE BUG contained
37- syn match cangjieComment / \v\/\/ .*/ contains =cangjieTodo
38- syn region cangjieComment start =/ \/\* / end =/ \*\/ / contains =cangjieTodo,@Spell
36+ syn keyword cangjieTodo TODO FIXME XXX NOTE BUG contained
37+ syn match cangjieDocKeyword / \v\c\@ (brief|param|return|note|warning|deprecated)/ contained
38+ syn match cangjieDocKeyword / \v\c\@ (author|version|date|since|file|copyright)/ contained
39+ syn match cangjieDocKeyword / \v\c\@ (details|link|see|throws|exception|example)/ contained
40+ syn match cangjieDocKeyword / \v\c\@ (private|protected|public|internal)/ contained
41+ syn match cangjieComment / \v\/\/ .*/ contains =cangjieTodo,cangjieDocKeyword
42+ syn region cangjieComment start =/ \/\* / end =/ \*\/ / contains =cangjieTodo,cangjieDocKeyword,@spell
3943
4044" 2. keywords
4145syn keyword cangjieDeclaration abstract extend macro foreign
@@ -65,27 +69,48 @@ syn match cangjieTypeName /\h\w*/ contained
6569syn region cangjieSpIdentifier start =/ `/ end =/ `/ oneline
6670
6771" 6. types
68- syn keyword cangjieSpType Any Nothing Range Unit Iterable
69- syn keyword cangjieArrayType Array ArrayList VArray
70- syn keyword cangjieHashType HashMap HashSet
72+ syn keyword cangjieSpType Nothing Range Unit LibC Duration DefaultHasher
73+ syn keyword cangjieArrayType Array VArray
7174syn keyword cangjieCommonType Bool Byte Rune String
7275syn keyword cangjieFloatType Float16 Float32 Float64
73- syn keyword cangjieIntType Int8 Int16 Int32 Int64 IntNative
74- syn keyword cangjieUIntType UInt8 UInt16 UInt32 UInt64 UIntNative
76+ syn keyword cangjieIntType Int Int8 Int16 Int32 Int64 IntNative
77+ syn keyword cangjieUIntType UInt UInt8 UInt16 UInt32 UInt64 UIntNative
78+ syn keyword cangjieFFIType CPointer CPointerHandle CPointerResource CString CStringResource
7579syn cluster cangjieTypeCluster contains =
7680 \ cangjieSpType,
7781 \ cangjieArrayType,
78- \ cangjieHashType,
7982 \ cangjieCommonType,
8083 \ cangjieFloatType,
8184 \ cangjieIntType,
82- \ cangjieUIntType
85+ \ cangjieUIntType,
86+ \ cangjieFFIType
87+
88+ " 6.1. builtin function/interface/class
89+ syn keyword cangjieCoreFunc acquireArrayRawData alignOf eprint eprintln ifNone ifSome max min
90+ syn keyword cangjieCoreFunc print println readln refEq releaseArrayRawData sizeOf sleep zeroValue
91+ syn keyword cangjieCoreItf Any Hasher ThreadContext Countable Collection Less Greater
92+ syn keyword cangjieCoreItf LessOrEqual GreaterOrEqual Comparable Equal NotEqual Equatable
93+ syn keyword cangjieCoreItf Hashable Iterable Resource ToString CType
94+ syn keyword cangjieCoreClass ArrayIterator Box Future Iterator Object RangeIterator
95+ syn keyword cangjieCoreClass StackTraceElement StringBuilder Thread ThreadLocal
96+ syn keyword cangjieCoreError ArithmeticException Error Exception IllegalArgumentException
97+ syn keyword cangjieCoreError IllegalFormatException IllegalMemoryException IllegalStateException
98+ syn keyword cangjieCoreError IncompatiblePackageException IndexOutOfBoundsException InternalError
99+ syn keyword cangjieCoreError NegativeArraySizeException NoneValueException OutOfMemoryError
100+ syn keyword cangjieCoreError OverflowException SpawnException StackOverflowError
101+ syn keyword cangjieCoreError TimeoutException UnsupportedException
102+ syn cluster cangjieBuiltinCluster contains =
103+ \ cangjieCoreFunc,
104+ \ cangjieCoreItf,
105+ \ cangjieCoreClass,
106+ \ cangjieCoreError
83107
84108" 7. character and strings
85109syn cluster cangjieInterpolatedPart contains =
86110 \ @c angjieKeywordCluster,
87111 \ cangjieSpIdentifier,
88112 \ @c angjieTypeCluster,
113+ \ @c angjieBuiltinCluster,
89114 \ @c angjieNumberCluster,
90115 \ cangjieOperator
91116syn region cangjieInterpolation contained keepend start =/ \$ {/ end =/ }/ contains =@cangjieInterpolatedPart
@@ -139,6 +164,7 @@ syn region cangjieFoldBrackets transparent fold start='\[' end='\]' contains=ALL
139164" finally, link the syntax groups to the highlight groups
140165if s: enabled (' comment' )
141166 hi def link cangjieTodo Todo
167+ hi def link cangjieDocKeyword SpecialComment
142168 hi def link cangjieComment Comment
143169endif
144170if s: enabled (' identifier' )
@@ -151,6 +177,12 @@ if s:enabled('keyword')
151177 hi def link cangjieVariable Keyword
152178 hi def link cangjieOption Keyword
153179endif
180+ if s: enabled (' builtin' )
181+ hi def link cangjieCoreFunc Function
182+ hi def link cangjieCoreItf Type
183+ hi def link cangjieCoreClass Type
184+ hi def link cangjieCoreError Structure
185+ endif
154186if s: enabled (' macro' )
155187 hi def link cangjieMacro PreProc
156188endif
@@ -178,11 +210,11 @@ if s:enabled('type')
178210 hi def link cangjieTypeName Type
179211 hi def link cangjieSpType Type
180212 hi def link cangjieArrayType Type
181- hi def link cangjieHashType Type
182213 hi def link cangjieCommonType Type
183214 hi def link cangjieFloatType Type
184215 hi def link cangjieIntType Type
185216 hi def link cangjieUIntType Type
217+ hi def link cangjieFFIType Type
186218endif
187219
188220let b: current_syntax = " cangjie"
0 commit comments