Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add circom tree-sitter, syntax-highlighting, and lsp support #11676

Merged
merged 7 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
19 changes: 18 additions & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bicep-langserver = { command = "bicep-langserver" }
bitbake-language-server = { command = "bitbake-language-server" }
bufls = { command = "bufls", args = ["serve"] }
cairo-language-server = { command = "cairo-language-server", args = [] }
circom-lsp = { command = "circom-lsp" }
cl-lsp = { command = "cl-lsp", args = [ "stdio" ] }
clangd = { command = "clangd" }
clojure-lsp = { command = "clojure-lsp" }
Expand Down Expand Up @@ -3785,4 +3786,20 @@ indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "thrift"
source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-thrift" , rev = "68fd0d80943a828d9e6f49c58a74be1e9ca142cf" }
source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-thrift" , rev = "68fd0d80943a828d9e6f49c58a74be1e9ca142cf" }

[[language]]
name = "circom"
scope = "source.circom"
injection-regex = "circom"
file-types = ["circom"]
roots = ["package.json"]
comment-tokens = "//"
indent = { tab-width = 4, unit = " " }
auto-format = false
language-servers = ["circom-lsp"]

[[grammar]]
name = "circom"
source = { git = "https://github.com/Decurity/tree-sitter-circom", rev = "02150524228b1e6afef96949f2d6b7cc0aaf999e" }

134 changes: 134 additions & 0 deletions runtime/queries/circom/highlights.scm
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
; identifiers
; -----------
(identifier) @variable

; Pragma
; -----------
(pragma_directive) @tag

; Include
; -----------
(include_directive) @include
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved

; Literals
; --------

(string) @string
(int_literal) @number
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved
(comment) @comment

; Definitions
; -----------

(function_definition
name: (identifier) @function)

(template_definition
name: (identifier) @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) @property)
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved


; Tokens
; -------

; Keywords

[
"public"
"signal"
"var"
"include"
"input"
"output"
"public"
"component"
] @keyword

[
"for"
"while"
] @repeat
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved

[
"if"
"else"
] @conditional
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved

[
"return"
] @keyword.return
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved

[
"function"
"template"
] @keyword.function


; Punctuation

[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket


[
"."
","
] @punctuation.delimiter


; Operators

[
"&&"
"||"
">>"
"<<"
"&"
"^"
"|"
"+"
"-"
"*"
"/"
"%"
"**"
"<"
"<="
"=="
"!="
">="
">"
"!"
"~"
"-"
"+"
"++"
"--"
] @operator

[
"<=="
"==>"
"<--"
"-->"
"==="
] @assignment
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 9 additions & 0 deletions runtime/queries/circom/locals.scm
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
Loading