aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Zelinskie2024-02-12 01:28:52 +0000
committerGitHub2024-02-12 01:28:52 +0000
commitd9f7aaacaf65272dfce092954ec49a78961e8112 (patch)
tree780f6885391b872fed90617c380258f87c093a87
parent7d8ce1a4000939bb1d1e0a67277f7733735607c7 (diff)
languages: add CEL, SpiceDB schema language (#9296)
* languages: add CEL language and grammar * languages: add spicedb schema language * chore: docgen * runtime/queries: refine spicedb & cel highlights Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * languages: update spicedb --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
-rw-r--r--book/src/generated/lang-support.md2
-rw-r--r--languages.toml24
-rw-r--r--runtime/queries/cel/highlights.scm66
-rw-r--r--runtime/queries/spicedb/highlights.scm47
-rw-r--r--runtime/queries/spicedb/injections.scm5
-rw-r--r--runtime/queries/spicedb/tags.scm4
6 files changed, 148 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index c91b9ae1..9131ff58 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -14,6 +14,7 @@
| cabal | | | | `haskell-language-server-wrapper` |
| cairo | ✓ | ✓ | ✓ | `cairo-language-server` |
| capnp | ✓ | | ✓ | |
+| cel | ✓ | | | |
| clojure | ✓ | | | `clojure-lsp` |
| cmake | ✓ | ✓ | ✓ | `cmake-language-server` |
| comment | ✓ | | | |
@@ -154,6 +155,7 @@
| smithy | ✓ | | | `cs` |
| sml | ✓ | | | |
| solidity | ✓ | | | `solc` |
+| spicedb | ✓ | | | |
| sql | ✓ | | | |
| sshclientconfig | ✓ | | | |
| starlark | ✓ | ✓ | | |
diff --git a/languages.toml b/languages.toml
index c2432c27..6fc81181 100644
--- a/languages.toml
+++ b/languages.toml
@@ -515,6 +515,30 @@ name = "c-sharp"
source = { git = "https://github.com/tree-sitter/tree-sitter-c-sharp", rev = "5b60f99545fea00a33bbfae5be956f684c4c69e2" }
[[language]]
+name = "cel"
+scope = "source.cel"
+injection-regex = "cel"
+file-types = ["cel"]
+comment-token = "//"
+indent = { tab-width = 2, unit = " " }
+
+[[grammar]]
+name = "cel"
+source = { git = "https://github.com/bufbuild/tree-sitter-cel", rev = "9f2b65da14c216df53933748e489db0f11121464" }
+
+[[language]]
+name = "spicedb"
+scope = "source.zed"
+injection-regex = "spicedb"
+file-types = ["zed"]
+comment-token = "//"
+indent = { tab-width = 2, unit = " " }
+
+[[grammar]]
+name = "spicedb"
+source = { git = "https://github.com/jzelinskie/tree-sitter-spicedb", rev = "a4e4645651f86d6684c15dfa9931b7841dc52a66" }
+
+[[language]]
name = "go"
scope = "source.go"
injection-regex = "go"
diff --git a/runtime/queries/cel/highlights.scm b/runtime/queries/cel/highlights.scm
new file mode 100644
index 00000000..ab3bae5a
--- /dev/null
+++ b/runtime/queries/cel/highlights.scm
@@ -0,0 +1,66 @@
+; Operators
+
+[
+ "-"
+ "!"
+ "*"
+ "/"
+ "&&"
+ "%"
+ "+"
+ "<"
+ "<="
+ "=="
+ ">"
+ ">="
+ "||"
+] @operator
+
+; Keywords
+
+[
+"in"
+] @keyword
+
+; Function calls
+
+(call_expression
+ function: (identifier) @function)
+
+(member_call_expression
+ function: (identifier) @function)
+
+; Identifiers
+
+(select_expression
+ operand: (identifier) @type)
+
+(select_expression
+ operand: (select_expression
+ member: (identifier) @type))
+
+(identifier) @variable.other.member
+
+; Literals
+
+[
+ (double_quote_string_literal)
+ (single_quoted_string_literal)
+ (triple_double_quote_string_literal)
+ (triple_single_quoted_string_literal)
+] @string
+
+[
+ (int_literal)
+ (uint_literal)
+] @constant.numeric.integer
+(float_literal) @constant.numeric.float
+
+[
+ (true)
+ (false)
+] @constant.builtin.boolean
+
+(null) @constant.builtin
+
+(comment) @comment
diff --git a/runtime/queries/spicedb/highlights.scm b/runtime/queries/spicedb/highlights.scm
new file mode 100644
index 00000000..63c93955
--- /dev/null
+++ b/runtime/queries/spicedb/highlights.scm
@@ -0,0 +1,47 @@
+; highlights.scm
+
+[
+ "definition"
+ "caveat"
+ "permission"
+ "relation"
+ "nil"
+] @keyword
+
+[
+ ","
+ ":"
+] @punctuation.delimiter
+
+[
+ "("
+ ")"
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ "|"
+ "+"
+ "-"
+ "&"
+ "#"
+ "->"
+ "="
+] @operator
+("with") @keyword.operator
+
+[
+ "nil"
+ "*"
+] @constant.builtin
+
+(comment) @comment
+(type_identifier) @type
+(cel_type_identifier) @type
+(cel_variable_identifier) @variable.parameter
+(field_identifier) @variable.other.member
+[
+ (func_identifier)
+ (method_identifier)
+] @function.method
diff --git a/runtime/queries/spicedb/injections.scm b/runtime/queries/spicedb/injections.scm
new file mode 100644
index 00000000..f8cafc9d
--- /dev/null
+++ b/runtime/queries/spicedb/injections.scm
@@ -0,0 +1,5 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
+
+((caveat_expr) @injection.content
+ (#set! injection.language "cel"))
diff --git a/runtime/queries/spicedb/tags.scm b/runtime/queries/spicedb/tags.scm
new file mode 100644
index 00000000..a8fe932b
--- /dev/null
+++ b/runtime/queries/spicedb/tags.scm
@@ -0,0 +1,4 @@
+(object_definition
+ name: (type_identifier) @name) @definition.type
+
+(type_identifier) @name @reference.type