-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add circom tree-sitter, syntax-highlighting, and lsp support (#11676)
* add circom tree-sitter and lsp support * add circom syntax highlighting queries * cargo xtask docgen * updated highlights to reflect helix themes typing * bugfix: ~= operator causing issues * minor adjustment: add = and ; operator and delimiter
- Loading branch information
Showing
4 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
; identifiers | ||
; ----------- | ||
(identifier) @variable | ||
|
||
; Pragma | ||
; ----------- | ||
(pragma_directive) @keyword.directive | ||
|
||
; Include | ||
; ----------- | ||
(include_directive) @keyword.directive | ||
|
||
; Literals | ||
; -------- | ||
(string) @string | ||
(int_literal) @constant.numeric.integer | ||
(comment) @comment | ||
|
||
; Definitions | ||
; ----------- | ||
(function_definition | ||
name: (identifier) @keyword.function) | ||
|
||
(template_definition | ||
name: (identifier) @keyword.function) | ||
|
||
; Use contructor coloring for special functions | ||
(main_component_definition) @constructor | ||
|
||
; Invocations | ||
(call_expression . (identifier) @function) | ||
|
||
; Function parameters | ||
(parameter name: (identifier) @variable.parameter) | ||
|
||
; Members | ||
(member_expression property: (property_identifier) @variable.other.member) | ||
|
||
; Tokens | ||
; ------- | ||
|
||
; Keywords | ||
[ | ||
"signal" | ||
"var" | ||
"component" | ||
] @keyword.storage.type | ||
|
||
[ "include" ] @keyword.control.import | ||
|
||
[ | ||
"public" | ||
"input" | ||
"output" | ||
] @keyword.storage.modifier | ||
|
||
[ | ||
"for" | ||
"while" | ||
] @keyword.control.repeat | ||
|
||
[ | ||
"if" | ||
"else" | ||
] @keyword.control.conditional | ||
|
||
[ | ||
"return" | ||
] @keyword.control.return | ||
|
||
[ | ||
"function" | ||
"template" | ||
] @keyword.function | ||
|
||
; Punctuation | ||
[ | ||
"(" | ||
")" | ||
"[" | ||
"]" | ||
"{" | ||
"}" | ||
] @punctuation.bracket | ||
|
||
[ | ||
"." | ||
"," | ||
";" | ||
] @punctuation.delimiter | ||
|
||
; Operators | ||
; https://docs.circom.io/circom-language/basic-operators | ||
[ | ||
"=" | ||
"?" | ||
"&&" | ||
"||" | ||
"!" | ||
"<" | ||
">" | ||
"<=" | ||
">=" | ||
"==" | ||
"!=" | ||
"+" | ||
"-" | ||
"*" | ||
"**" | ||
"/" | ||
"\\" | ||
"%" | ||
"+=" | ||
"-=" | ||
"*=" | ||
"**=" | ||
"/=" | ||
"\\=" | ||
"%=" | ||
"++" | ||
"--" | ||
"&" | ||
"|" | ||
"~" | ||
"^" | ||
">>" | ||
"<<" | ||
"&=" | ||
"|=" | ||
; "\~=" ; bug, uncomment and circom will not highlight | ||
"^=" | ||
">>=" | ||
"<<=" | ||
] @operator | ||
|
||
[ | ||
"<==" | ||
"==>" | ||
"<--" | ||
"-->" | ||
"===" | ||
] @operator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(function_definition) @local.scope | ||
(template_definition) @local.scope | ||
(main_component_definition) @local.scope | ||
(block_statement) @local.scope | ||
|
||
(parameter name: (identifier) @local.definition) @local.definition | ||
|
||
|
||
(identifier) @local.reference |