diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index f223c8b22..8a8c9fa83 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -19,6 +19,7 @@ | cairo | ✓ | ✓ | ✓ | `cairo-language-server` | | capnp | ✓ | | ✓ | | | cel | ✓ | | | | +| circom | ✓ | | | `circom-lsp` | | clojure | ✓ | | | `clojure-lsp` | | cmake | ✓ | ✓ | ✓ | `cmake-language-server` | | comment | ✓ | | | | diff --git a/languages.toml b/languages.toml index 9e1be0ac2..cf1d5ae13 100644 --- a/languages.toml +++ b/languages.toml @@ -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" } @@ -3788,3 +3789,19 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "thrift" 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" } + diff --git a/runtime/queries/circom/highlights.scm b/runtime/queries/circom/highlights.scm new file mode 100644 index 000000000..1d310bd8e --- /dev/null +++ b/runtime/queries/circom/highlights.scm @@ -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 diff --git a/runtime/queries/circom/locals.scm b/runtime/queries/circom/locals.scm new file mode 100644 index 000000000..e0ea12de0 --- /dev/null +++ b/runtime/queries/circom/locals.scm @@ -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 \ No newline at end of file