]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(cangjie): Update syntax script
authorNeila <wu.junkai@qq.com>
Tue, 6 Jan 2026 10:18:09 +0000 (10:18 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 6 Jan 2026 10:18:09 +0000 (10:18 +0000)
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>
runtime/doc/syntax.txt
runtime/syntax/cangjie.vim

index 236340daec28f4f4f44ea0d641a30fa4bcfe07b4..700d51c213d524269fab1b617179f2b674de9bc0 100644 (file)
@@ -1,4 +1,4 @@
-*syntax.txt*   For Vim version 9.1.  Last change: 2025 Oct 14
+*syntax.txt*   For Vim version 9.1.  Last change: 2026 Jan 06
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1125,6 +1125,7 @@ new-generation language oriented to full-scenario intelligence.
 All highlighting is enabled by default.  To disable highlighting for a
 specific group, set the corresponding variable to 0 in your |vimrc|.
 All options to disable highlighting are: >
+       :let g:cangjie_builtin_color = 0
        :let g:cangjie_comment_color = 0
        :let g:cangjie_identifier_color = 0
        :let g:cangjie_keyword_color = 0
index 1e8b87219845ac941e8f154517c75e104a45a44d..d8194a9274971e2e3be2ae561884748023897d7e 100644 (file)
@@ -2,7 +2,7 @@
 " Language: Cangjie
 " Maintainer: Wu Junkai <wu.junkai@qq.com>
 " URL: https://github.com/WuJunkai2004/cangjie.vim
-" Last Change: 2025 Oct 12
+" Last Change: 2026 Jan 5
 "
 " The Cangjie programming language is a new-generation programming
 " language oriented to full-scenario intelligence. It features
@@ -33,9 +33,13 @@ endfunction
 syn case match
 
 " 1. comments
-syn keyword cangjieTodo        TODO FIXME XXX NOTE BUG contained
-syn match   cangjieComment /\v\/\/.*/                  contains=cangjieTodo
-syn region  cangjieComment start=/\/\*/ end=/\*\//     contains=cangjieTodo,@Spell
+syn keyword    cangjieTodo     TODO FIXME XXX NOTE BUG contained
+syn match      cangjieDocKeyword /\v\c\@(brief|param|return|note|warning|deprecated)/ contained
+syn match      cangjieDocKeyword /\v\c\@(author|version|date|since|file|copyright)/ contained
+syn match      cangjieDocKeyword /\v\c\@(details|link|see|throws|exception|example)/ contained
+syn match      cangjieDocKeyword /\v\c\@(private|protected|public|internal)/ contained
+syn match      cangjieComment /\v\/\/.*/               contains=cangjieTodo,cangjieDocKeyword
+syn region     cangjieComment start=/\/\*/ end=/\*\//  contains=cangjieTodo,cangjieDocKeyword,@spell
 
 " 2. keywords
 syn keyword cangjieDeclaration abstract extend macro foreign
@@ -65,27 +69,48 @@ syn match cangjieTypeName /\h\w*/ contained
 syn region cangjieSpIdentifier start=/`/ end=/`/ oneline
 
 " 6. types
-syn keyword cangjieSpType      Any Nothing Range Unit Iterable
-syn keyword cangjieArrayType   Array ArrayList VArray
-syn keyword cangjieHashType    HashMap HashSet
+syn keyword cangjieSpType      Nothing Range Unit LibC Duration DefaultHasher
+syn keyword cangjieArrayType   Array VArray
 syn keyword cangjieCommonType  Bool Byte Rune String
 syn keyword cangjieFloatType   Float16 Float32 Float64
-syn keyword cangjieIntType     Int8 Int16 Int32 Int64 IntNative
-syn keyword cangjieUIntType    UInt8 UInt16 UInt32 UInt64 UIntNative
+syn keyword cangjieIntType     Int Int8 Int16 Int32 Int64 IntNative
+syn keyword cangjieUIntType    UInt UInt8 UInt16 UInt32 UInt64 UIntNative
+syn keyword cangjieFFIType     CPointer CPointerHandle CPointerResource CString CStringResource
 syn cluster cangjieTypeCluster contains=
        \ cangjieSpType,
        \ cangjieArrayType,
-       \ cangjieHashType,
        \ cangjieCommonType,
        \ cangjieFloatType,
        \ cangjieIntType,
-       \ cangjieUIntType
+       \ cangjieUIntType,
+       \ cangjieFFIType
+
+" 6.1. builtin function/interface/class
+syn keyword cangjieCoreFunc    acquireArrayRawData alignOf eprint eprintln ifNone ifSome max min
+syn keyword cangjieCoreFunc    print println readln refEq releaseArrayRawData sizeOf sleep zeroValue
+syn keyword cangjieCoreItf     Any Hasher ThreadContext Countable Collection Less Greater
+syn keyword cangjieCoreItf     LessOrEqual GreaterOrEqual Comparable Equal NotEqual Equatable
+syn keyword cangjieCoreItf     Hashable Iterable Resource ToString CType
+syn keyword cangjieCoreClass   ArrayIterator Box Future Iterator Object RangeIterator
+syn keyword cangjieCoreClass   StackTraceElement StringBuilder Thread ThreadLocal
+syn keyword cangjieCoreError   ArithmeticException Error Exception IllegalArgumentException
+syn keyword cangjieCoreError   IllegalFormatException IllegalMemoryException IllegalStateException
+syn keyword cangjieCoreError   IncompatiblePackageException IndexOutOfBoundsException InternalError
+syn keyword cangjieCoreError   NegativeArraySizeException NoneValueException OutOfMemoryError
+syn keyword cangjieCoreError   OverflowException SpawnException StackOverflowError
+syn keyword cangjieCoreError   TimeoutException UnsupportedException
+syn cluster cangjieBuiltinCluster contains=
+       \ cangjieCoreFunc,
+       \ cangjieCoreItf,
+       \ cangjieCoreClass,
+       \ cangjieCoreError
 
 " 7. character and strings
 syn cluster cangjieInterpolatedPart contains=
        \ @cangjieKeywordCluster,
        \ cangjieSpIdentifier,
        \ @cangjieTypeCluster,
+       \ @cangjieBuiltinCluster,
        \ @cangjieNumberCluster,
        \ cangjieOperator
 syn region  cangjieInterpolation contained keepend start=/\${/ end=/}/ contains=@cangjieInterpolatedPart
@@ -139,6 +164,7 @@ syn region cangjieFoldBrackets transparent fold start='\[' end='\]' contains=ALL
 " finally, link the syntax groups to the highlight groups
 if s:enabled('comment')
        hi def link cangjieTodo                 Todo
+       hi def link cangjieDocKeyword           SpecialComment
        hi def link cangjieComment              Comment
 endif
 if s:enabled('identifier')
@@ -151,6 +177,12 @@ if s:enabled('keyword')
        hi def link cangjieVariable             Keyword
        hi def link cangjieOption               Keyword
 endif
+if s:enabled('builtin')
+       hi def link cangjieCoreFunc             Function
+       hi def link cangjieCoreItf              Type
+       hi def link cangjieCoreClass            Type
+       hi def link cangjieCoreError            Structure
+endif
 if s:enabled('macro')
        hi def link cangjieMacro                PreProc
 endif
@@ -178,11 +210,11 @@ if s:enabled('type')
        hi def link cangjieTypeName             Type
        hi def link cangjieSpType               Type
        hi def link cangjieArrayType            Type
-       hi def link cangjieHashType             Type
        hi def link cangjieCommonType           Type
        hi def link cangjieFloatType            Type
        hi def link cangjieIntType              Type
        hi def link cangjieUIntType             Type
+       hi def link cangjieFFIType              Type
 endif
 
 let b:current_syntax = "cangjie"