codekingpro/portable-devtools
114k
1" Vim syntax file2" Language: Cangjie3" Maintainer: Wu Junkai <wu.junkai@qq.com>4" URL: https://github.com/WuJunkai2004/cangjie.vim5" Last Change: 2026 Jan 56"7" The Cangjie programming language is a new-generation programming8" language oriented to full-scenario intelligence. It features9" native intelligence, being naturally suitable for all scenarios,10" high performance and strong security. It is mainly applied in11" scenarios such as native applications and service applications12" of HarmonyOS NEXT, providing developers with a good programming13" experience.14"15" For more information, see:16" - https://cangjie-lang.cn/17" - https://gitcode.com/Cangjie18 19" quit when a syntax file was already loaded20if exists("b:current_syntax")21 finish22endif23 24let s:save_cpo = &cpo25set cpo&vim26 27" 0. check the user's settings28" use let g:cangjie_<item>_color to enable/disable syntax highlighting29function! s:enabled(item) abort30 return get(g:, 'cangjie_' . a:item . '_color', 1)31endfunction32 33syn case match34 35" 1. comments36syn keyword cangjieTodo TODO FIXME XXX NOTE BUG contained37syn match cangjieDocKeyword /\v\c\@(brief|param|return|note|warning|deprecated)/ contained38syn match cangjieDocKeyword /\v\c\@(author|version|date|since|file|copyright)/ contained39syn match cangjieDocKeyword /\v\c\@(details|link|see|throws|exception|example)/ contained40syn match cangjieDocKeyword /\v\c\@(private|protected|public|internal)/ contained41syn match cangjieComment /\v\/\/.*/ contains=cangjieTodo,cangjieDocKeyword42syn region cangjieComment start=/\/\*/ end=/\*\// contains=cangjieTodo,cangjieDocKeyword,@spell43 44" 2. keywords45syn keyword cangjieDeclaration abstract extend macro foreign46syn keyword cangjieDeclaration interface open operator override private prop protected47syn keyword cangjieDeclaration public redef static type48syn keyword cangjieStatement as break case catch continue do else finally for in49syn keyword cangjieStatement if in is match quote return spawn super synchronized50syn keyword cangjieStatement throw try unsafe where while51syn keyword cangjieIdentlike false init main this true52syn keyword cangjieVariable const let var53syn keyword cangjieOption Option Some None54syn keyword cangjieDeclaration func struct class enum import package nextgroup=cangjieTypeName skipwhite55syn cluster cangjieKeywordCluster contains=56 \ cangjieDeclaration,57 \ cangjieStatement,58 \ cangjieIdentlike,59 \ cangjieVariable,60 \ cangjieOption61 62" 3. macro (e.g., @override)63syn match cangjieMacro /@\h\w*/64 65" 4. Type and Function Names66syn match cangjieTypeName /\h\w*/ contained67 68" 5. specail identifiers69syn region cangjieSpIdentifier start=/`/ end=/`/ oneline70 71" 6. types72syn keyword cangjieSpType Nothing Range Unit LibC Duration DefaultHasher73syn keyword cangjieArrayType Array VArray74syn keyword cangjieCommonType Bool Byte Rune String75syn keyword cangjieFloatType Float16 Float32 Float6476syn keyword cangjieIntType Int Int8 Int16 Int32 Int64 IntNative77syn keyword cangjieUIntType UInt UInt8 UInt16 UInt32 UInt64 UIntNative78syn keyword cangjieFFIType CPointer CPointerHandle CPointerResource CString CStringResource79syn cluster cangjieTypeCluster contains=80 \ cangjieSpType,81 \ cangjieArrayType,82 \ cangjieCommonType,83 \ cangjieFloatType,84 \ cangjieIntType,85 \ cangjieUIntType,86 \ cangjieFFIType87 88" 6.1. builtin function/interface/class89syn keyword cangjieCoreFunc acquireArrayRawData alignOf eprint eprintln ifNone ifSome max min90syn keyword cangjieCoreFunc print println readln refEq releaseArrayRawData sizeOf sleep zeroValue91syn keyword cangjieCoreItf Any Hasher ThreadContext Countable Collection Less Greater92syn keyword cangjieCoreItf LessOrEqual GreaterOrEqual Comparable Equal NotEqual Equatable93syn keyword cangjieCoreItf Hashable Iterable Resource ToString CType94syn keyword cangjieCoreClass ArrayIterator Box Future Iterator Object RangeIterator95syn keyword cangjieCoreClass StackTraceElement StringBuilder Thread ThreadLocal96syn keyword cangjieCoreError ArithmeticException Error Exception IllegalArgumentException97syn keyword cangjieCoreError IllegalFormatException IllegalMemoryException IllegalStateException98syn keyword cangjieCoreError IncompatiblePackageException IndexOutOfBoundsException InternalError99syn keyword cangjieCoreError NegativeArraySizeException NoneValueException OutOfMemoryError100syn keyword cangjieCoreError OverflowException SpawnException StackOverflowError101syn keyword cangjieCoreError TimeoutException UnsupportedException102syn cluster cangjieBuiltinCluster contains=103 \ cangjieCoreFunc,104 \ cangjieCoreItf,105 \ cangjieCoreClass,106 \ cangjieCoreError107 108" 7. character and strings109syn cluster cangjieInterpolatedPart contains=110 \ @cangjieKeywordCluster,111 \ cangjieSpIdentifier,112 \ @cangjieTypeCluster,113 \ @cangjieBuiltinCluster,114 \ @cangjieNumberCluster,115 \ cangjieOperator116syn region cangjieInterpolation contained keepend start=/\${/ end=/}/ contains=@cangjieInterpolatedPart117syn match cangjieEscape /\v\\u\{[0-9a-fA-F]{1,8}\}|\\./ contained118syn match cangjieRuneError /\v[rb]'([^'\\]|\\.)*'/119syn match cangjieRuneError /\v[rb]"([^"\\]|\\.)*"/120syn match cangjieRune /\vr'(\\u\{[0-9a-fA-F]{1,8}\}|\\.|[^'\\])'/ contains=cangjieEscape121syn match cangjieRune /\vr"(\\u\{[0-9a-fA-F]{1,8}\}|\\.|[^"\\])"/ contains=cangjieEscape122syn match cangjieRune /\vb'(\\u\{[0-9a-fA-F]{1,8}\}|\\.|[^'\\])'/ contains=cangjieEscape123syn region cangjieString start=/"/ skip=/\\\\\|\\"/ end=/"/ oneline contains=cangjieInterpolation,cangjieEscape124syn region cangjieString start=/'/ skip=/\\\\\|\\'/ end=/'/ oneline contains=cangjieInterpolation,cangjieEscape125syn region cangjieString start=/"""/ skip=/\\\\\|\\"/ end=/"""/ contains=cangjieInterpolation,cangjieEscape keepend126syn region cangjieString start=/'''/ skip=/\\\\\|\\'/ end=/'''/ contains=cangjieInterpolation,cangjieEscape keepend127syn region cangjieRawString start='\z(#*\)#"' end='"#\z1'128syn region cangjieRawString start='\z(#*\)#\'' end='\'#\z1'129 130" 8. number131syn match cangjieHexFloatNumber /\v\c<0x([0-9a-f_]+\.?|[0-9a-f_]*\.[0-9a-f_]+)[p][-+]?\d[0-9_]*>/132syn match cangjieFloatNumber /\v\c<\d[0-9_]*\.\d[0-9_]*([ep][-+]?\d[0-9_]*)?(f(16|32|64))?>/133syn match cangjieFloatNumber /\v\c<\d[0-9_]*\.([ep][-+]?\d[0-9_]*)?(f(16|32|64))?>/134syn match cangjieFloatNumber /\v\c\.\d[0-9_]*([ep][-+]?\d[0-9_]*)?(f(16|32|64))?>/135syn match cangjieScienceNumber /\v\c<\d[0-9_]*[e][-+]?\d[0-9_]*(f(16|32|64))?>/136syn match cangjieHexNumber /\v\c<0x[0-9a-f_]+([iu](8|16|32|64))?>/137syn match cangjieOctalNumber /\v\c<0o[0-7_]+([iu](8|16|32|64))?>/138syn match cangjieBinaryNumber /\v\c<0b[01_]+([iu](8|16|32|64))?>/139syn match cangjieDecimalNumber /\v\c<\d[0-9_]*([iu](8|16|32|64))?>/140syn cluster cangjieNumberCluster contains=141 \ cangjieHexFloatNumber,142 \ cangjieFloatNumber,143 \ cangjieScienceNumber,144 \ cangjieHexNumber,145 \ cangjieOctalNumber,146 \ cangjieBinaryNumber,147 \ cangjieDecimalNumber148 149" 9. operators150syn match cangjieOperator /[-+%<>!&|^*=]=\?/151syn match cangjieOperator /\/\%(=\|\ze[^/*]\)/152syn match cangjieOperator /\%(<<\|>>\|&^\)=\?/153syn match cangjieOperator /:=\|||\|<-\|++\|--/154syn match cangjieOperator /[~]/155syn match cangjieOperator /[:]/156syn match cangjieOperator /\.\./157syn match cangjieVarArgs /\.\.\./158 159" 10. folding160syn region cangjieFoldBraces transparent fold start='{' end='}' contains=ALLBUT,cangjieComment161syn region cangjieFoldParens transparent fold start='(' end=')' contains=ALLBUT,cangjieComment162syn region cangjieFoldBrackets transparent fold start='\[' end='\]' contains=ALLBUT,cangjieComment163 164" finally, link the syntax groups to the highlight groups165if s:enabled('comment')166 hi def link cangjieTodo Todo167 hi def link cangjieDocKeyword SpecialComment168 hi def link cangjieComment Comment169endif170if s:enabled('identifier')171 hi def link cangjieSpIdentifier Identifier172endif173if s:enabled('keyword')174 hi def link cangjieDeclaration Keyword175 hi def link cangjieStatement Statement176 hi def link cangjieIdentlike Keyword177 hi def link cangjieVariable Keyword178 hi def link cangjieOption Keyword179endif180if s:enabled('builtin')181 hi def link cangjieCoreFunc Function182 hi def link cangjieCoreItf Type183 hi def link cangjieCoreClass Type184 hi def link cangjieCoreError Structure185endif186if s:enabled('macro')187 hi def link cangjieMacro PreProc188endif189if s:enabled('number')190 hi def link cangjieHexFloatNumber Number191 hi def link cangjieFloatNumber Float192 hi def link cangjieScienceNumber Float193 hi def link cangjieHexNumber Number194 hi def link cangjieOctalNumber Number195 hi def link cangjieBinaryNumber Number196 hi def link cangjieDecimalNumber Number197endif198if s:enabled('operator')199 hi def link cangjieOperator Operator200 hi def link cangjieVarArgs Operator201endif202if s:enabled('string')203 hi def link cangjieRune Character204 hi def link cangjieRuneError Error205 hi def link cangjieString String206 hi def link cangjieRawString String207 hi def link cangjieEscape SpecialChar208endif209if s:enabled('type')210 hi def link cangjieTypeName Type211 hi def link cangjieSpType Type212 hi def link cangjieArrayType Type213 hi def link cangjieCommonType Type214 hi def link cangjieFloatType Type215 hi def link cangjieIntType Type216 hi def link cangjieUIntType Type217 hi def link cangjieFFIType Type218endif219 220let b:current_syntax = "cangjie"221 222let &cpo = s:save_cpo223unlet s:save_cpo224 225" vim: ts=8 sw=8 noet226 