Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml19
-rw-r--r--runtime/queries/clarity/highlights.scm103
3 files changed, 123 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 1172f988..cd937ca2 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -21,6 +21,7 @@
| capnp | ✓ | | ✓ | |
| cel | ✓ | | | |
| circom | ✓ | | | `circom-lsp` |
+| clarity | ✓ | | | `clarinet` |
| clojure | ✓ | | | `clojure-lsp` |
| cmake | ✓ | ✓ | ✓ | `cmake-language-server` |
| codeql | ✓ | ✓ | | `codeql` |
diff --git a/languages.toml b/languages.toml
index c908e48a..acf519c9 100644
--- a/languages.toml
+++ b/languages.toml
@@ -261,6 +261,10 @@ enable = true
[language-server.vscode-eslint-language-server.config.workingDirectory]
mode = "location"
+[language-server.clarinet]
+command = "clarinet"
+args = ["lsp"]
+
[[language]]
name = "rust"
scope = "source.rust"
@@ -4371,3 +4375,18 @@ injection-regex = "rust-format-args"
[[grammar]]
name = "rust-format-args"
source = { git = "https://github.com/nik-rev/tree-sitter-rustfmt", rev = "2ca0bdd763d0c9dbb1d0bd14aea7544cbe81309c" }
+
+[[language]]
+name = "clarity"
+scope = "source.clar"
+injection-regex = "clarity"
+file-types = ["clar"]
+roots = ["Clarinet.toml"]
+comment-tokens = ";;"
+indent = { tab-width = 2, unit = " " }
+language-servers = [ "clarinet" ]
+
+[[grammar]]
+name = "clarity"
+source = { git = "https://github.com/xlittlerag/tree-sitter-clarity", rev = "7fa54825fdd971a1a676f885384f024fe2b7384a" }
+
diff --git a/runtime/queries/clarity/highlights.scm b/runtime/queries/clarity/highlights.scm
new file mode 100644
index 00000000..a3a2fd4c
--- /dev/null
+++ b/runtime/queries/clarity/highlights.scm
@@ -0,0 +1,103 @@
+; Comments
+(comment) @comment
+
+; Literals
+[
+ (int_lit)
+ (uint_lit)
+] @constant.numeric.integer
+
+[
+ (bool_lit)
+ (none_lit)
+] @constant.builtin
+
+[
+ (ascii_string_lit)
+ (utf8_string_lit)
+] @string
+
+[
+ (buffer_lit)
+ (standard_principal_lit)
+ (contract_principal_lit)
+] @string.special
+
+; Types
+[
+ (native_type)
+ (trait_type)
+] @type
+
+; Punctuation
+[
+ "("
+ ")"
+ "{"
+ "}"
+ "<"
+ ">"
+] @punctuation.bracket
+
+[
+ ","
+] @punctuation.delimiter
+
+; Keywords
+(list_lit_token) @keyword
+(some_lit ("some") @keyword)
+(response_lit [
+ "ok"
+ "err"
+] @keyword)
+
+[
+ "+"
+ "-"
+ "*"
+ "/"
+ "mod"
+ "pow"
+ "<"
+ "<="
+ ">"
+ ">="
+ "and"
+ "or"
+ "xor"
+] @keyword.operator
+
+; Functions
+(function_signature (identifier) @function)
+(function_signature_for_trait (identifier) @function)
+(contract_function_call operator: (identifier) @function)
+
+(basic_native_form operator: (native_identifier) @function.builtin)
+[
+ "let"
+] @function.builtin
+
+[
+ "impl-trait"
+ "use-trait"
+ "define-trait"
+ "define-read-only"
+ "define-private"
+ "define-public"
+ "define-data-var"
+ "define-fungible-token"
+ "define-non-fungible-token"
+ "define-constant"
+ "define-map"
+] @function.special
+
+; Variables and parameters
+(function_parameter) @variable.parameter
+(trait_usage trait_alias: (identifier) @type.parameter)
+
+(tuple_lit key: (identifier) @variable)
+(tuple_type key: (identifier) @variable)
+(tuple_type_for_trait key: (identifier) @variable)
+
+(global) @variable.builtin
+