mirror of
https://github.com/vim/vim.git
synced 2025-08-24 19:45:50 -04:00
patch 9.1.1647: filetype: Cangjie files are not recognized
Problem: filetype: Cangjie files are not recognized Solution: Detect *.cj files as cangjie filetype, include a syntax plugin (WuJunkai2004) This commit introduces a new syntax highlighting file for the Cangjie programming language, includes 4 parts as required: - The main syntax file: runtime/syntax/cangjie.vim - The filetype detection rule in: runtime/filetype.vim - The documentation update in: runtime/doc/syntax.txt - Some menus References: - https://gitcode.com/Cangjie - https://cangjie-lang.cn/ fixes: 18014 closes: #18027 Signed-off-by: WuJunkai2004 <wujunkai20041123@outlook.com> Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
a2f13bf782
commit
0c4405a6b2
1
.github/MAINTAINERS
vendored
1
.github/MAINTAINERS
vendored
@ -449,6 +449,7 @@ runtime/syntax/bzr.vim @hdima
|
|||||||
runtime/syntax/cabal.vim @coot
|
runtime/syntax/cabal.vim @coot
|
||||||
runtime/syntax/cabalconfig.vim @coot
|
runtime/syntax/cabalconfig.vim @coot
|
||||||
runtime/syntax/cabalproject.vim @coot
|
runtime/syntax/cabalproject.vim @coot
|
||||||
|
runtime/syntax/cangjie.vim @WuJunkai2004
|
||||||
runtime/syntax/cf.vim @ernstvanderlinden
|
runtime/syntax/cf.vim @ernstvanderlinden
|
||||||
runtime/syntax/chatito.vim @ObserverOfTime
|
runtime/syntax/chatito.vim @ObserverOfTime
|
||||||
runtime/syntax/chicken.vim @evhan
|
runtime/syntax/chicken.vim @evhan
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
*syntax.txt* For Vim version 9.1. Last change: 2025 Aug 10
|
*syntax.txt* For Vim version 9.1. Last change: 2025 Aug 18
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -1116,6 +1116,23 @@ in the "after" directory in 'runtimepath'. For Unix this would be
|
|||||||
syn sync fromstart
|
syn sync fromstart
|
||||||
set foldmethod=syntax
|
set foldmethod=syntax
|
||||||
|
|
||||||
|
CANGJIE *cangjie.vim* *ft-cangjie-syntax*
|
||||||
|
|
||||||
|
This file provides syntax highlighting for the Cangjie programming language, a
|
||||||
|
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_comment_color = 0
|
||||||
|
:let g:cangjie_identifier_color = 0
|
||||||
|
:let g:cangjie_keyword_color = 0
|
||||||
|
:let g:cangjie_macro_color = 0
|
||||||
|
:let g:cangjie_number_color = 0
|
||||||
|
:let g:cangjie_operator_color = 0
|
||||||
|
:let g:cangjie_string_color = 0
|
||||||
|
:let g:cangjie_type_color = 0
|
||||||
|
|
||||||
CH *ch.vim* *ft-ch-syntax*
|
CH *ch.vim* *ft-ch-syntax*
|
||||||
|
|
||||||
C/C++ interpreter. Ch has similar syntax highlighting to C and builds upon
|
C/C++ interpreter. Ch has similar syntax highlighting to C and builds upon
|
||||||
|
@ -6486,6 +6486,7 @@ c_space_errors syntax.txt /*c_space_errors*
|
|||||||
c_syntax_for_h syntax.txt /*c_syntax_for_h*
|
c_syntax_for_h syntax.txt /*c_syntax_for_h*
|
||||||
c_wildchar cmdline.txt /*c_wildchar*
|
c_wildchar cmdline.txt /*c_wildchar*
|
||||||
call() builtin.txt /*call()*
|
call() builtin.txt /*call()*
|
||||||
|
cangjie.vim syntax.txt /*cangjie.vim*
|
||||||
carriage-return intro.txt /*carriage-return*
|
carriage-return intro.txt /*carriage-return*
|
||||||
case change.txt /*case*
|
case change.txt /*case*
|
||||||
catch-all eval.txt /*catch-all*
|
catch-all eval.txt /*catch-all*
|
||||||
@ -7424,6 +7425,7 @@ ft-bash-syntax syntax.txt /*ft-bash-syntax*
|
|||||||
ft-basic-syntax syntax.txt /*ft-basic-syntax*
|
ft-basic-syntax syntax.txt /*ft-basic-syntax*
|
||||||
ft-c-omni insert.txt /*ft-c-omni*
|
ft-c-omni insert.txt /*ft-c-omni*
|
||||||
ft-c-syntax syntax.txt /*ft-c-syntax*
|
ft-c-syntax syntax.txt /*ft-c-syntax*
|
||||||
|
ft-cangjie-syntax syntax.txt /*ft-cangjie-syntax*
|
||||||
ft-ch-syntax syntax.txt /*ft-ch-syntax*
|
ft-ch-syntax syntax.txt /*ft-ch-syntax*
|
||||||
ft-changelog-plugin filetype.txt /*ft-changelog-plugin*
|
ft-changelog-plugin filetype.txt /*ft-changelog-plugin*
|
||||||
ft-changelog-syntax syntax.txt /*ft-changelog-syntax*
|
ft-changelog-syntax syntax.txt /*ft-changelog-syntax*
|
||||||
|
@ -2433,6 +2433,9 @@ au BufNewFile,BufRead *.il,*.ils,*.cdf setf skill
|
|||||||
" Cadence
|
" Cadence
|
||||||
au BufNewFile,BufRead *.cdc setf cdc
|
au BufNewFile,BufRead *.cdc setf cdc
|
||||||
|
|
||||||
|
" Cangjie
|
||||||
|
au BufNewFile,BufRead *.cj setf cangjie
|
||||||
|
|
||||||
" SLRN
|
" SLRN
|
||||||
au BufNewFile,BufRead .slrnrc setf slrnrc
|
au BufNewFile,BufRead .slrnrc setf slrnrc
|
||||||
au BufNewFile,BufRead *.score setf slrnsc
|
au BufNewFile,BufRead *.score setf slrnsc
|
||||||
|
@ -124,6 +124,7 @@ SynMenu C.C++:cpp
|
|||||||
SynMenu C.C#:cs
|
SynMenu C.C#:cs
|
||||||
SynMenu C.Cabal\ Haskell\ build\ file:cabal
|
SynMenu C.Cabal\ Haskell\ build\ file:cabal
|
||||||
SynMenu C.Calendar:calendar
|
SynMenu C.Calendar:calendar
|
||||||
|
SynMenu C.Cangjie:cangjie
|
||||||
SynMenu C.Cascading\ Style\ Sheets:css
|
SynMenu C.Cascading\ Style\ Sheets:css
|
||||||
SynMenu C.CDL:cdl
|
SynMenu C.CDL:cdl
|
||||||
SynMenu C.Cdrdao\ TOC:cdrtoc
|
SynMenu C.Cdrdao\ TOC:cdrtoc
|
||||||
|
@ -110,6 +110,7 @@ an 50.20.110 &Syntax.C.C++ :cal SetSyn("cpp")<CR>
|
|||||||
an 50.20.120 &Syntax.C.C# :cal SetSyn("cs")<CR>
|
an 50.20.120 &Syntax.C.C# :cal SetSyn("cs")<CR>
|
||||||
an 50.20.130 &Syntax.C.Cabal\ Haskell\ build\ file :cal SetSyn("cabal")<CR>
|
an 50.20.130 &Syntax.C.Cabal\ Haskell\ build\ file :cal SetSyn("cabal")<CR>
|
||||||
an 50.20.140 &Syntax.C.Calendar :cal SetSyn("calendar")<CR>
|
an 50.20.140 &Syntax.C.Calendar :cal SetSyn("calendar")<CR>
|
||||||
|
an 50.20.140 &Syntax.C.Cangjie :cal SetSyn("cangjie")<CR>
|
||||||
an 50.20.150 &Syntax.C.Cascading\ Style\ Sheets :cal SetSyn("css")<CR>
|
an 50.20.150 &Syntax.C.Cascading\ Style\ Sheets :cal SetSyn("css")<CR>
|
||||||
an 50.20.160 &Syntax.C.CDL :cal SetSyn("cdl")<CR>
|
an 50.20.160 &Syntax.C.CDL :cal SetSyn("cdl")<CR>
|
||||||
an 50.20.170 &Syntax.C.Cdrdao\ TOC :cal SetSyn("cdrtoc")<CR>
|
an 50.20.170 &Syntax.C.Cdrdao\ TOC :cal SetSyn("cdrtoc")<CR>
|
||||||
|
153
runtime/syntax/cangjie.vim
Normal file
153
runtime/syntax/cangjie.vim
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
" Vim syntax file
|
||||||
|
" Language: Cangjie
|
||||||
|
" Maintainer: Wu Junkai <wu.junkai@qq.com>
|
||||||
|
" Last Change: 2025 Aug 17
|
||||||
|
"
|
||||||
|
" The Cangjie programming language is a new-generation programming
|
||||||
|
" language oriented to full-scenario intelligence. It features
|
||||||
|
" native intelligence, being naturally suitable for all scenarios,
|
||||||
|
" high performance and strong security. It is mainly applied in
|
||||||
|
" scenarios such as native applications and service applications
|
||||||
|
" of HarmonyOS NEXT, providing developers with a good programming
|
||||||
|
" experience.
|
||||||
|
"
|
||||||
|
" For more information, see:
|
||||||
|
" - https://cangjie-lang.cn/
|
||||||
|
" - https://gitcode.com/Cangjie
|
||||||
|
|
||||||
|
" quit when a syntax file was already loaded
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:save_cpo = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
" 0. check the user's settings
|
||||||
|
" use let g:cangjie_<item>_color to enable/disable syntax highlighting
|
||||||
|
function! s:enabled(item) abort
|
||||||
|
return get(g:, 'cangjie_' . a:item . '_color', 1)
|
||||||
|
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
|
||||||
|
|
||||||
|
" 2. keywords
|
||||||
|
syn keyword cangjieDeclaration abstract extend macro foreign
|
||||||
|
syn keyword cangjieDeclaration interface open operator override private prop protected
|
||||||
|
syn keyword cangjieDeclaration public redef static type
|
||||||
|
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 cangjieDeclaration func struct class enum import package nextgroup=cangjieTypeName skipwhite
|
||||||
|
syn cluster cangjieKeywordCluster contains=cangjieDeclaration,cangjieStatement,cangjieIdentlike,cangjieVariable,cangjieOption
|
||||||
|
|
||||||
|
" 3. macro (e.g., @override)
|
||||||
|
syn match cangjieMacro /@\h\w*/
|
||||||
|
|
||||||
|
" 4. Type and Function Names
|
||||||
|
syn match cangjieTypeName /\h\w*/ contained
|
||||||
|
|
||||||
|
" 5. specail identifiers
|
||||||
|
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 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
|
||||||
|
|
||||||
|
" 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 region cangjieRawString start='\z(#*\)#"' end='"#\z1'
|
||||||
|
syn region cangjieRawString start='\z(#*\)#\'' end='\'#\z1'
|
||||||
|
|
||||||
|
" 8. number
|
||||||
|
syn match cangjieFloatNumber /\v\c<\d[0-9_]*\.\d[0-9_]*([ep][-+]?\d[0-9_]*)?(f(16|32|64))?>/
|
||||||
|
syn match cangjieFloatNumber /\v\c<\d[0-9_]*\.([ep][-+]?\d[0-9_]*)?(f(16|32|64))?>/
|
||||||
|
syn match cangjieFloatNumber /\v\c\.\d[0-9_]*([ep][-+]?\d[0-9_]*)?(f(16|32|64))?>/
|
||||||
|
syn match cangjieScienceNumber /\v\c<\d[0-9_]*[e][-+]?\d[0-9_]*>/
|
||||||
|
syn match cangjieHexNumber /\v\c<0x[0-9a-f_]+([iu](8|16|32|64))?>/
|
||||||
|
syn match cangjieOctalNumber /\v\c<0o[0-7_]+([iu](8|16|32|64))?>/
|
||||||
|
syn match cangjieBinaryNumber /\v\c<0b[01_]+([iu](8|16|32|64))?>/
|
||||||
|
syn match cangjieDecimalNumber /\v\c<\d[0-9_]*([iu](8|16|32|64))?>/
|
||||||
|
syn cluster cangjieNumberCluster contains=cangjieFloatNumber,cangjieScienceNumber,cangjieHexNumber,cangjieOctalNumber,cangjieBinaryNumber,cangjieDecimalNumber
|
||||||
|
|
||||||
|
" 9. operators
|
||||||
|
syn match cangjieOperator /[-+%<>!&|^*=]=\?/
|
||||||
|
syn match cangjieOperator /\/\%(=\|\ze[^/*]\)/
|
||||||
|
syn match cangjieOperator /\%(<<\|>>\|&^\)=\?/
|
||||||
|
syn match cangjieOperator /:=\|||\|<-\|++\|--/
|
||||||
|
syn match cangjieOperator /[~]/
|
||||||
|
syn match cangjieOperator /[:]/
|
||||||
|
syn match cangjieOperator /\.\./
|
||||||
|
syn match cangjieVarArgs /\.\.\./
|
||||||
|
|
||||||
|
" finally, link the syntax groups to the highlight groups
|
||||||
|
if s:enabled('comment')
|
||||||
|
hi def link cangjieTodo Todo
|
||||||
|
hi def link cangjieComment Comment
|
||||||
|
endif
|
||||||
|
if s:enabled('identifier')
|
||||||
|
hi def link cangjieSpIdentifier Identifier
|
||||||
|
endif
|
||||||
|
if s:enabled('keyword')
|
||||||
|
hi def link cangjieDeclaration Keyword
|
||||||
|
hi def link cangjieStatement Statement
|
||||||
|
hi def link cangjieIdentlike Keyword
|
||||||
|
hi def link cangjieVariable Keyword
|
||||||
|
hi def link cangjieOption Keyword
|
||||||
|
endif
|
||||||
|
if s:enabled('macro')
|
||||||
|
hi def link cangjieMacro PreProc
|
||||||
|
endif
|
||||||
|
if s:enabled('number')
|
||||||
|
hi def link cangjieFloatNumber Float
|
||||||
|
hi def link cangjieScienceNumber Float
|
||||||
|
hi def link cangjieHexNumber Number
|
||||||
|
hi def link cangjieOctalNumber Number
|
||||||
|
hi def link cangjieBinaryNumber Number
|
||||||
|
hi def link cangjieDecimalNumber Number
|
||||||
|
endif
|
||||||
|
if s:enabled('operator')
|
||||||
|
hi def link cangjieOperator Operator
|
||||||
|
hi def link cangjieVarArgs Operator
|
||||||
|
endif
|
||||||
|
if s:enabled('string')
|
||||||
|
hi def link cangjieRune Character
|
||||||
|
hi def link cangjieString String
|
||||||
|
hi def link cangjieRawString String
|
||||||
|
endif
|
||||||
|
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
|
||||||
|
endif
|
||||||
|
|
||||||
|
let b:current_syntax = "cangjie"
|
||||||
|
|
||||||
|
let &cpo = s:save_cpo
|
||||||
|
unlet s:save_cpo
|
@ -156,6 +156,7 @@ def s:GetFilenameChecks(): dict<list<string>>
|
|||||||
cabalproject: ['cabal.project', 'cabal.project.local'],
|
cabalproject: ['cabal.project', 'cabal.project.local'],
|
||||||
cairo: ['file.cairo'],
|
cairo: ['file.cairo'],
|
||||||
calendar: ['calendar', '/.calendar/file', '/share/calendar/any/calendar.file', '/share/calendar/calendar.file', 'any/share/calendar/any/calendar.file', 'any/share/calendar/calendar.file'],
|
calendar: ['calendar', '/.calendar/file', '/share/calendar/any/calendar.file', '/share/calendar/calendar.file', 'any/share/calendar/any/calendar.file', 'any/share/calendar/calendar.file'],
|
||||||
|
cangjie: ['file.cj'],
|
||||||
capnp: ['file.capnp'],
|
capnp: ['file.capnp'],
|
||||||
catalog: ['catalog', 'sgml.catalogfile', 'sgml.catalog', 'sgml.catalog-file'],
|
catalog: ['catalog', 'sgml.catalogfile', 'sgml.catalog', 'sgml.catalog-file'],
|
||||||
cdc: ['file.cdc'],
|
cdc: ['file.cdc'],
|
||||||
|
@ -719,6 +719,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1647,
|
||||||
/**/
|
/**/
|
||||||
1646,
|
1646,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user