Skip to content

Commit

Permalink
Merge pull request #2 from janezpodhostnik/update-tree-sitter
Browse files Browse the repository at this point in the history
Update tree sitter and bump version
  • Loading branch information
janezpodhostnik authored Aug 19, 2024
2 parents b7ce17c + 537fb0f commit 2c2fde6
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cadence"
version = "0.0.1"
version = "0.0.2"
edition = "2021"

[lib]
Expand Down
4 changes: 2 additions & 2 deletions extension.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id = "cadence"
name = "Cadence Syntax Highlighting"
version = "0.0.1"
version = "0.0.2"
schema_version = 1
authors = [
"Janez Podhostnik <[email protected]>",
Expand All @@ -11,7 +11,7 @@ repository = "https://github.com/janezpodhostnik/cadence.zed"

[grammars.cadence]
repository = "https://github.com/bluesign/cadence-tree-sitter.git"
commit = "1d6a4fbd3e068e01546474589c777498d4ccfd72"
commit = "67f1b5e92159c3e3e6cf37ce6e77ec72dfaa1af8"

[language_servers.cadence]
name = "cadence"
Expand Down
91 changes: 69 additions & 22 deletions languages/cadence/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,36 +1,83 @@
[
(blockComment)
(lineComment)
] @comment @spell

(compositeDeclaration) @type
(importDeclaration) @include
(identifier) @variable
(addressLocation) @variable
(field) @field

(stringLiteral) @string
(typeAnnotation) @type
(TypeIdentifier) @type
(TypeBuiltin) @type.builtin
(Identifier) @variable
((Identifier) @variable.builtin
(#eq? @variable.builtin "self"))

(InitDeclaration) @constructor
(SpecialFunctionDeclaration) @function.builtin
(SpecialFunctionIdentifier) @function.builtin
(FunctionDeclaration name: (Identifier) @function)

(parameter identifier: (identifier) @parameter)
(StringLiteral) @string
(PathExpression) @string
(PathExpression (Identifier) @string)
(Address) @number
(IntegerLiteral) @number
(FixedPointLiteral) @number
(BooleanLiteral) @boolean

(Parameter Identifier: (Identifier) @variable.parameter)
[
"var"
"let"
] @type.qualifier

(access) @keyword
(Access) @keyword
(transactionDeclaration) @keyword
(EntitlementIdentifier) @label

(InterfaceMarker) @keyword
(CompositeDeclaration) @keyword

[
"contract"
"event"
"struct"
"resource"
"interface"
"enum"
"event"
"enum"
"fun"
"pre"
"post"
"execute"
"return"
"import"
"from"
"view"
"create"
"if"
"mapping"
] @keyword

(invokeExpression target: (identifierExpression) @function.call) ; foo()
(invokeExpression target: (memberAccessExpression) @function.call) ; foo()
[
"("
")"
"}"
"{"
"["
"]"
] @punctuation.bracket

[
"."
","
";"
"?"
":"
] @punctuation.delimiter

(MultiplicativeOp) @operator
(AdditiveOp) @operator
(BitwiseShiftOp) @operator
(BitwiseAnd) @operator
(BitwiseXor) @operator
(BitwiseOr) @operator
(RelationalOP) @operator
(NilCoalescing) @operator
(EqualityOp) @operator
(LogicalAnd) @operator
(LogicalOr) @operator
(Transfer) @operator
(SwapStatement) @operator
(Move) @operator

(integerLiteral) @number
(Comment) @comment
14 changes: 1 addition & 13 deletions languages/cadence/locals.scm
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
(importDeclaration (identifier) @definition.import)
(functionDeclaration identifier: (identifier) @definition.function)
(compositeDeclaration identifier: (identifier) @definition.namespace)

; Scopes
[
(compositeDeclaration)
(forStatement)
(ifStatement)
(switchStatement)
(functionDeclaration)
(compositeDeclaration)
] @scope
(Program) @local.scope

0 comments on commit 2c2fde6

Please sign in to comment.