Skip to content

Commit

Permalink
Improve solidity highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer authored and Vulpesx committed Jun 7, 2024
1 parent 82d91fd commit dea12ed
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions runtime/queries/solidity/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; Pragma
(pragma_directive) @tag
(solidity_version_comparison_operator _ @tag)
(pragma_directive) @keyword.directive
(solidity_version_comparison_operator _ @keyword.directive)


; Literals
Expand All @@ -20,7 +20,7 @@
[
(true)
(false)
] @constant.builtin
] @constant.builtin.boolean

(comment) @comment

Expand All @@ -29,7 +29,12 @@
; -----------

(type_name) @type
(primitive_type) @type

[
(primitive_type)
(number_unit)
] @type.builtin

(user_defined_type (identifier) @type)
(type_alias (identifier) @type)

Expand Down Expand Up @@ -61,6 +66,7 @@

; Use constructor coloring for special functions
(constructor_definition "constructor" @constructor)
(error_declaration "error" @constructor)
(fallback_receive_definition "receive" @constructor)
(fallback_receive_definition "fallback" @constructor)

Expand Down Expand Up @@ -96,35 +102,39 @@
(meta_type_expression "type" @keyword)
[
"abstract"
"pragma"
"contract"
"interface"
"library"
"is"
"struct"
"enum"
"event"
"using"
"assembly"
"emit"

"public"
"internal"
"private"
"external"
"pure"
"view"
"payable"

"modifier"
"memory"
"storage"
"calldata"
"var"
"constant"
"let"
(virtual)
(override_specifier)
(yul_leave)
] @keyword

[
"memory"
"storage"
"calldata"
"constant"
] @keyword.storage.modifier

[
"for"
"while"
Expand All @@ -144,6 +154,7 @@
[
"try"
"catch"
"revert"
] @keyword.control.exception

[
Expand All @@ -154,6 +165,7 @@
"function" @keyword.function

"import" @keyword.control.import
"using" @keyword.control.import
(import_directive "as" @keyword.control.import)
(import_directive "from" @keyword.control.import)
(event_parameter "indexed" @keyword)
Expand All @@ -173,6 +185,9 @@
[
"."
","
":"
"->"
"=>"
] @punctuation.delimiter


Expand Down Expand Up @@ -215,6 +230,7 @@
"new"
] @keyword.operator

; TODO: move to top when order swapped
; identifiers
; -----------
((identifier) @variable.builtin
Expand Down

0 comments on commit dea12ed

Please sign in to comment.