runtime(cangjie): Fixes and improvements for syntax script
Commit:
https://github.com/vim/vim/commit/37c8ce7fac3b60457382aeb7573766177e4df269
Author: Wu Junkai <[email protected]>
Date: Sun Oct 12 14:10:34 2025 +0000
runtime(cangjie): Fixes and improvements for syntax script
Housekeeping:
- Add GitHub repository link
- Update Last Change date
Style:
- Add Vim modeline for consistent formatting
- Unify indentation style (spaces to tabs)
- Wrap long cluster definitions for readability
New Features:
- Add highlighting for escape sequences
- Add error highlighting for invalid rune literals
- Add syntax-based folding support
Fixes:
- Fix rune matching to allow only a single character/escape
- Fix highlighting for double-quoted rune literals
- Fix highlighting for floats with exponents and type suffixes
Co-authored-by: dkearns <[email protected]>
Signed-off-by: Wu Junkai <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/syntax/cangjie.vim b/runtime/syntax/cangjie.vim
index 8438a16e9..1e8b87219 100644
--- a/runtime/syntax/cangjie.vim
+++ b/runtime/syntax/cangjie.vim
@@ -1,7 +1,8 @@
" Vim syntax file
" Language: Cangjie
" Maintainer: Wu Junkai <[email protected]>
-" Last Change: 2025 Aug 17
+" URL: https://github.com/WuJunkai2004/cangjie.vim
+" Last Change: 2025 Oct 12
"
" The Cangjie programming language is a new-generation programming
" language oriented to full-scenario intelligence. It features
@@ -33,7 +34,7 @@ syn case match
" 1. comments
syn keyword cangjieTodo TODO FIXME XXX NOTE BUG contained
-syn match cangjieComment / \/\/.*/
contains=cangjieTodo
+syn match cangjieComment / \/\/.*/ contains=cangjieTodo
syn region cangjieComment start=/\/\*/ end=/\*\//
contains=cangjieTodo,@Spell
" 2. keywords
@@ -44,10 +45,15 @@ syn keyword cangjieStatement as break case catch
continue do else finally for in
syn keyword cangjieStatement if in is match quote return spawn super
synchronized
syn keyword cangjieStatement throw try unsafe where while
syn keyword cangjieIdentlike false init main this true
-syn keyword cangjieVariable const let var
-syn keyword cangjieOption Option Some None
+syn keyword cangjieVariable const let var
+syn keyword cangjieOption Option Some None
syn keyword cangjieDeclaration func struct class enum import package
nextgroup=cangjieTypeName skipwhite
-syn cluster cangjieKeywordCluster
contains=cangjieDeclaration,cangjieStatement,cangjieIdentlike,cangjieVariable,cangjieOption
+syn cluster cangjieKeywordCluster contains=
+ \ cangjieDeclaration,
+ \ cangjieStatement,
+ \ cangjieIdentlike,
+ \ cangjieVariable,
+ \ cangjieOption
" 3. macro (e.g., @override)
syn match cangjieMacro /@\h\w*/
@@ -59,37 +65,61 @@ syn match cangjieTypeName /\h\w*/ contained
syn region cangjieSpIdentifier start=/`/ end=/`/ oneline
" 6. types
-syn keyword cangjieSpType Any Nothing Range Unit Iterable
+syn keyword cangjieSpType Any Nothing Range Unit Iterable
syn keyword cangjieArrayType Array ArrayList VArray
-syn keyword cangjieHashType HashMap HashSet
+syn keyword cangjieHashType HashMap HashSet
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 cluster cangjieTypeCluster
contains=cangjieSpType,cangjieArrayType,cangjieHashType,cangjieCommonType,cangjieFloatType,cangjieIntType,cangjieUIntType
+syn keyword cangjieIntType Int8 Int16 Int32 Int64 IntNative
+syn keyword cangjieUIntType UInt8 UInt16 UInt32 UInt64 UIntNative
+syn cluster cangjieTypeCluster contains=
+ \ cangjieSpType,
+ \ cangjieArrayType,
+ \ cangjieHashType,
+ \ cangjieCommonType,
+ \ cangjieFloatType,
+ \ cangjieIntType,
+ \ cangjieUIntType
" 7. character and strings
-syn cluster cangjieInterpolatedPart
contains=@cangjieKeywordCluster,cangjieSpIdentifier,@cangjieTypeCluster,@cangjieNumberCluster,cangjieOperator
-syn region cangjieInterpolation contained keepend start=/\${/ end=/}/
contains=@cangjieInterpolatedPart matchgroup=cangjieInterpolationDelimiter
-syn region cangjieRune start=/r'/ skip=/\\\|\'/ end=/'/ oneline
-syn region cangjieRune start=/b'/ skip=/\\\|\'/ end=/'/ oneline
-syn region cangjieString start=/"/ skip=/\\\|\"/ end=/"/ oneline
contains=cangjieInterpolation
-syn region cangjieString start=/'/ skip=/\\\|\'/ end=/'/ oneline
contains=cangjieInterpolation
-syn region cangjieString start=/"""/ skip=/\\\|\"/ end=/"""/
contains=cangjieInterpolation keepend
-syn region cangjieString start=/'''/ skip=/\\\|\'/ end=/'''/
contains=cangjieInterpolation keepend
+syn cluster cangjieInterpolatedPart contains=
+ \ @cangjieKeywordCluster,
+ \ cangjieSpIdentifier,
+ \ @cangjieTypeCluster,
+ \ @cangjieNumberCluster,
+ \ cangjieOperator
+syn region cangjieInterpolation contained keepend start=/\${/ end=/}/
contains=@cangjieInterpolatedPart
+syn match cangjieEscape / \u\{[0-9a-fA-F]{1,8}\}|\./ contained
+syn match cangjieRuneError / [rb]'([^'\]|\.)*'/
+syn match cangjieRuneError / [rb]"([^"\]|\.)*"/
+syn match cangjieRune / r'(\u\{[0-9a-fA-F]{1,8}\}|\.|[^'\])'/
contains=cangjieEscape
+syn match cangjieRune / r"(\u\{[0-9a-fA-F]{1,8}\}|\.|[^"\])"/
contains=cangjieEscape
+syn match cangjieRune / b'(\u\{[0-9a-fA-F]{1,8}\}|\.|[^'\])'/
contains=cangjieEscape
+syn region cangjieString start=/"/ skip=/\\\|\"/ end=/"/ oneline
contains=cangjieInterpolation,cangjieEscape
+syn region cangjieString start=/'/ skip=/\\\|\'/ end=/'/ oneline
contains=cangjieInterpolation,cangjieEscape
+syn region cangjieString start=/"""/ skip=/\\\|\"/ end=/"""/
contains=cangjieInterpolation,cangjieEscape keepend
+syn region cangjieString start=/'''/ skip=/\\\|\'/ end=/'''/
contains=cangjieInterpolation,cangjieEscape keepend
syn region cangjieRawString start='\z(#*\)#"' end='"#\z1'
syn region cangjieRawString start='\z(#*\)#\'' end='\'#\z1'
" 8. number
+syn match cangjieHexFloatNumber /
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1v7wqs-00AFvv-Rp%40256bit.org.