From e5422ec662395c014a28e6b6f8285c014b644473 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Tue, 9 Jan 2024 19:00:07 -0500 Subject: [PATCH 1/5] languages: add CEL language and grammar --- languages.toml | 12 ++++++ runtime/queries/cel/highlights.scm | 65 ++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 runtime/queries/cel/highlights.scm diff --git a/languages.toml b/languages.toml index 7983e75ace0e..60beea9912a1 100644 --- a/languages.toml +++ b/languages.toml @@ -491,6 +491,18 @@ args = { processId = "{0}" } 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 = "go" scope = "source.go" diff --git a/runtime/queries/cel/highlights.scm b/runtime/queries/cel/highlights.scm new file mode 100644 index 000000000000..e5a0a3faeae3 --- /dev/null +++ b/runtime/queries/cel/highlights.scm @@ -0,0 +1,65 @@ +; 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) @property + +; Literals + +[ + (double_quote_string_literal) + (single_quoted_string_literal) + (triple_double_quote_string_literal) + (triple_single_quoted_string_literal) +] @string + +[ + (int_literal) + (uint_literal) + (float_literal) +] @number + +[ + (true) + (false) + (null) +] @constant.builtin + +(comment) @comment From 2fb45f8587d4187e67bea9bae95bcae6229ce2ba Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Tue, 9 Jan 2024 19:02:09 -0500 Subject: [PATCH 2/5] languages: add spicedb schema language --- languages.toml | 12 +++++++ runtime/queries/spicedb/highlights.scm | 47 ++++++++++++++++++++++++++ runtime/queries/spicedb/injections.scm | 5 +++ runtime/queries/spicedb/tags.scm | 4 +++ 4 files changed, 68 insertions(+) create mode 100644 runtime/queries/spicedb/highlights.scm create mode 100644 runtime/queries/spicedb/injections.scm create mode 100644 runtime/queries/spicedb/tags.scm diff --git a/languages.toml b/languages.toml index 60beea9912a1..f25fa8ffc1e5 100644 --- a/languages.toml +++ b/languages.toml @@ -503,6 +503,18 @@ indent = { tab-width = 2, unit = " " } 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 = "04ea9c294b3e20f9e3433114fa138cc20dc92770" } + [[language]] name = "go" scope = "source.go" diff --git a/runtime/queries/spicedb/highlights.scm b/runtime/queries/spicedb/highlights.scm new file mode 100644 index 000000000000..863905474769 --- /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) @property +[ + (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 000000000000..f8cafc9d13bf --- /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 000000000000..a8fe932b683a --- /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 From e683ce89920bdc214c8313cf0a080ab46f7f32aa Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Thu, 11 Jan 2024 13:02:29 -0500 Subject: [PATCH 3/5] chore: docgen --- book/src/generated/lang-support.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index ee01c40309c3..4da614f08a85 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 | ✓ | | | | @@ -153,6 +154,7 @@ | smithy | ✓ | | | `cs` | | sml | ✓ | | | | | solidity | ✓ | | | `solc` | +| spicedb | ✓ | | | | | sql | ✓ | | | | | sshclientconfig | ✓ | | | | | starlark | ✓ | ✓ | | | From 23145550a0348fa975552f9ea5c01439669f807f Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Tue, 6 Feb 2024 10:47:31 -0500 Subject: [PATCH 4/5] runtime/queries: refine spicedb & cel highlights Co-authored-by: Michael Davis --- runtime/queries/cel/highlights.scm | 11 ++++++----- runtime/queries/spicedb/highlights.scm | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/runtime/queries/cel/highlights.scm b/runtime/queries/cel/highlights.scm index e5a0a3faeae3..ab3bae5a51d5 100644 --- a/runtime/queries/cel/highlights.scm +++ b/runtime/queries/cel/highlights.scm @@ -39,7 +39,7 @@ operand: (select_expression member: (identifier) @type)) -(identifier) @property +(identifier) @variable.other.member ; Literals @@ -53,13 +53,14 @@ [ (int_literal) (uint_literal) - (float_literal) -] @number +] @constant.numeric.integer +(float_literal) @constant.numeric.float [ (true) (false) - (null) -] @constant.builtin +] @constant.builtin.boolean + +(null) @constant.builtin (comment) @comment diff --git a/runtime/queries/spicedb/highlights.scm b/runtime/queries/spicedb/highlights.scm index 863905474769..63c939551ff0 100644 --- a/runtime/queries/spicedb/highlights.scm +++ b/runtime/queries/spicedb/highlights.scm @@ -40,7 +40,7 @@ (type_identifier) @type (cel_type_identifier) @type (cel_variable_identifier) @variable.parameter -(field_identifier) @property +(field_identifier) @variable.other.member [ (func_identifier) (method_identifier) From 1f3a7a4be33ad05f4dc1009696db03ddb7ed118e Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Wed, 7 Feb 2024 20:25:03 -0500 Subject: [PATCH 5/5] languages: update spicedb --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index f25fa8ffc1e5..ba0748c2eb05 100644 --- a/languages.toml +++ b/languages.toml @@ -513,7 +513,7 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "spicedb" -source = { git = "https://github.com/jzelinskie/tree-sitter-spicedb", rev = "04ea9c294b3e20f9e3433114fa138cc20dc92770" } +source = { git = "https://github.com/jzelinskie/tree-sitter-spicedb", rev = "a4e4645651f86d6684c15dfa9931b7841dc52a66" } [[language]] name = "go"