Skip to content

Commit 77a59be

Browse files
WuJunkai2004chrisbra
authored andcommitted
runtime(cangjie): Update syntax script
This commit updates `syntax/cangjie.vim` to match the latest `std.core` library: New Features: * Documentation: Added highlighting for documentation keywords (e.g., `@param`, `@return`). * Standard Library: Added highlighting for `std.core` functions, interfaces, and classes. * Exceptions: Added highlighting for standard exception types. * FFI Support: Added highlighting for C interoperability types (e.g., `CPointer`). Improvements: * Configuration: Added a unified switch (`s:enabled('builtin')`) for standard library highlighting. * Type System: Updated `Int` and `UInt` aliases. * Interpolation: Enabled standard library highlighting inside string interpolation. * Cleanup: Removed non-core types like `ArrayList` and `HashMap`. closes: #19085 Signed-off-by: Neila <wu.junkai@qq.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent eb577f9 commit 77a59be

2 files changed

Lines changed: 46 additions & 13 deletions

File tree

runtime/doc/syntax.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*syntax.txt* For Vim version 9.1. Last change: 2025 Oct 14
1+
*syntax.txt* For Vim version 9.1. Last change: 2026 Jan 06
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1125,6 +1125,7 @@ new-generation language oriented to full-scenario intelligence.
11251125
All highlighting is enabled by default. To disable highlighting for a
11261126
specific group, set the corresponding variable to 0 in your |vimrc|.
11271127
All options to disable highlighting are: >
1128+
:let g:cangjie_builtin_color = 0
11281129
:let g:cangjie_comment_color = 0
11291130
:let g:cangjie_identifier_color = 0
11301131
:let g:cangjie_keyword_color = 0

runtime/syntax/cangjie.vim

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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
3333
syn 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
4145
syn keyword cangjieDeclaration abstract extend macro foreign
@@ -65,27 +69,48 @@ syn match cangjieTypeName /\h\w*/ contained
6569
syn 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
7174
syn keyword cangjieCommonType Bool Byte Rune String
7275
syn 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
7579
syn 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
85109
syn cluster cangjieInterpolatedPart contains=
86110
\ @cangjieKeywordCluster,
87111
\ cangjieSpIdentifier,
88112
\ @cangjieTypeCluster,
113+
\ @cangjieBuiltinCluster,
89114
\ @cangjieNumberCluster,
90115
\ cangjieOperator
91116
syn 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
140165
if s:enabled('comment')
141166
hi def link cangjieTodo Todo
167+
hi def link cangjieDocKeyword SpecialComment
142168
hi def link cangjieComment Comment
143169
endif
144170
if s:enabled('identifier')
@@ -151,6 +177,12 @@ if s:enabled('keyword')
151177
hi def link cangjieVariable Keyword
152178
hi def link cangjieOption Keyword
153179
endif
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
154186
if s:enabled('macro')
155187
hi def link cangjieMacro PreProc
156188
endif
@@ -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
186218
endif
187219

188220
let b:current_syntax = "cangjie"

0 commit comments

Comments
 (0)