Unnamed repository; edit this file 'description' to name the repository.
syntax: add grammar and highlighting for the alloy config lang (#13660)
Matt Conway 9 months ago
parent 8d2870b · commit d375f1e
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml12
-rw-r--r--runtime/queries/alloy/highlights.scm39
3 files changed, 52 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index cd937ca2..360e1a62 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -3,6 +3,7 @@
| ada | ✓ | ✓ | | `ada_language_server` |
| adl | ✓ | ✓ | ✓ | |
| agda | ✓ | | | |
+| alloy | ✓ | | | |
| amber | ✓ | | | |
| astro | ✓ | | | `astro-ls` |
| awk | ✓ | ✓ | | `awk-language-server` |
diff --git a/languages.toml b/languages.toml
index ce71ee06..b436baa5 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4390,3 +4390,15 @@ language-servers = [ "clarinet" ]
name = "clarity"
source = { git = "https://github.com/xlittlerag/tree-sitter-clarity", rev = "7fa54825fdd971a1a676f885384f024fe2b7384a" }
+[[language]]
+name = "alloy"
+scope = "source.alloy"
+injection-regex = "alloy"
+file-types = ["alloy"]
+comment-token = "//"
+block-comment-tokens = { start = "/*", end = "*/" }
+indent = { tab-width = 2, unit = " " }
+
+[[grammar]]
+name = "alloy"
+source = { git = "https://github.com/mattsre/tree-sitter-alloy", rev = "3e18eb4e97f06c57a3925f3d20bef6329a6eaef3" }
diff --git a/runtime/queries/alloy/highlights.scm b/runtime/queries/alloy/highlights.scm
new file mode 100644
index 00000000..e62970c6
--- /dev/null
+++ b/runtime/queries/alloy/highlights.scm
@@ -0,0 +1,39 @@
+; Literals
+; --------
+
+(boolean) @constant.builtin.boolean
+(comment) @comment
+(string) @string
+(number) @constant.numeric
+(null) @constant.builtin
+
+; Punctuation
+; -----------
+
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ "."
+ ","
+] @punctuation.delimiter
+
+[
+ "="
+] @operator
+
+; Function definitions
+;---------------------
+
+(function
+ name: (identifier) @function)
+
+
+(attribute (identifier) @variable.other.member)
+(block (identifier) @type.builtin)