Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
| cabal | | | | | | `haskell-language-server-wrapper` |
| caddyfile | ✓ | ✓ | ✓ | | | |
| cairo | ✓ | ✓ | ✓ | | | `cairo-language-server` |
| cangjie | ✓ | ✓ | ✓ | ✓ | | |
| capnp | ✓ | | ✓ | | | |
| cel | ✓ | | | | | |
| circom | ✓ | | | | | `circom-lsp` |
Expand Down
18 changes: 18 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4911,3 +4911,21 @@ block-comment-tokens = { start = "/*", end = "*/"}
[[grammer]]
name = "kcl"
source = { git = "https://github.com/KittyCAD/tree-sitter-kcl", rev = "8905e0bdbf5870b50bc3f24345f1af27746f42e8"}

[[language]]
name = "cangjie"
scope = "source.cangjie"
injection-regex = "cangjie"
file-types = ["cj"]
roots = ["cjpm.toml", "cjpm.lock"]
auto-format = true
comment-tokens = ["//"]
block-comment-tokens = [
{ start = "/*", end = "*/"},
{ start = "/**", end = "*/"}
]
indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "cangjie"
source = { git = "https://gitcode.com/Cangjie-SIG/tree-sitter-cangjie", rev = "4daa9e507385285883bdc1916a385baa5b7c5be4"}
161 changes: 161 additions & 0 deletions runtime/queries/cangjie/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@

(stringLiteral) @string
(booleanLiteral) @constant
(varBindingPattern) @variable
[
(integerLiteral)
(floatLiteral)
] @number
(modifiers) @keyword
(className) @type
(structName) @type
(interfaceName) @type
(returnType) @type
(Bool) @type
(thisSuperExpression) @variable.builtin

(funcName) @function
(propertyName) @property

[
(blockComment)
(lineComment)
] @comment

[
"Int8"
"Int16"
"Int32"
"Int64"
"IntNative"
"UInt8"
"UInt16"
"UInt32"
"UInt64"
"UIntNative"
"Float16"
"Float32"
"Float64"
"Rune"
"Bool"
"Unit"
"Nothing"
; "Thistype"
] @type

[
"struct"
"enum"
"package"
"import"
"class"
"interface"
"func"
"main"
"let"
"var"
"const"
"init"
"super"
"if"
"else"
"case"
"try"
"catch"
"finally"
"for"
"do"
"while"
"throw"
"return"
"continue"
"break"
"is"
"as"
"in"
"match"
"where"
"extend"
"macro"
"static"
"public"
"private"
"protected"
"internal"
"override"
"redef"
"abstract"
"open"
"operator"
"foreign"
"inout"
"prop"
"mut"
"unsafe"
"get"
"set"
"spawn"
"synchronized"
"type"
] @keyword

; operetors
[
"."
","
"("
")"
"["
"]"
"{"
"}"
"**"
"*"
"%"
"/"
"+"
"-"
"++"
"--"
"&&"
"||"
"!"
"&"
"|"
"^"
"<<"
">>"
":"
";"
"="
"+="
"-="
"*="
"**="
"/="
"%="
"&="
"|="
"^="
"<<="
">>="
"->"
"<-"
"=>"
"..="
".."
"@"
"?"
"<:"
"<"
">"
"<="
">="
"!="
"=="
"_"
"|>"
"~>"
"&&="
"||="
] @operator
37 changes: 37 additions & 0 deletions runtime/queries/cangjie/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
; 缩进规则
(classDefinition
(classBody) @indent.begin
)

(init) @indent.begin

(functionDefinition
(block) @indent.begin
)

(operatorFunctionDefinition
(block) @indent.begin
)

(callSuffix) @indent.begin

(arrayLiteral) @indent.begin

(ifExpression) @indent.begin

(matchExpression
(matchCase) @indent.begin
) @indent.begin

(forInExpression) @indent.begin

[
"]"
")"
"}"
] @indent.end @indent.branch

[
(lineComment)
(blockComment)
] @indent.auto
6 changes: 6 additions & 0 deletions runtime/queries/cangjie/tags.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(classDefinition (className) @definition.class)
(interfaceDefinition (interfaceName) @definition.interface)
(functionDefinition (funcName) @definition.function)
(macroDefinition (macroName) @definition.macro)
(structDefinition (structName) @definition.struct)
(typeAlias (typeAliasName) @definition.type)
41 changes: 41 additions & 0 deletions runtime/queries/cangjie/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
; Classes and similar constructs
[
(classDefinition (classBody) @class.inside)
(structDefinition (structBody) @class.inside)
(interfaceDefinition (interfaceBody) @class.inside)
(enumDefinition (enumBody) @class.inside)
(extendDefinition (extendBody) @class.inside)
] @class.around

; Functions
[
(functionDefinition (block) @function.inside)
(operatorFunctionDefinition (block) @function.inside)
(mainDefinition (block) @function.inside)
(propertyDefinition) ; TODO
(macroDefinition (block) @class.inside)
] @function.around

; Comments
[
(lineComment)
(blockComment)
] @comment.inside

[
(lineComment)+
(blockComment)
] @comment.around

; Parameters
[
(parameter)
(namedParameter)
] @parameter.inside

[
(typeParameters (identifier) @parameter.inside)
(lambdaParameters (lambdaParameter) @parameter.inside)
(parameterList)
(primaryInitParamList)
] @parameter.around