Skip to content

Commit

Permalink
languages: add CEL, SpiceDB schema language (helix-editor#9296)
Browse files Browse the repository at this point in the history
* languages: add CEL language and grammar

* languages: add spicedb schema language

* chore: docgen

* runtime/queries: refine spicedb & cel highlights

Co-authored-by: Michael Davis <[email protected]>

* languages: update spicedb

---------

Co-authored-by: Michael Davis <[email protected]>
  • Loading branch information
2 people authored and cosmikwolf committed Feb 26, 2024
1 parent dad2421 commit bb19f55
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 0 deletions.
2 changes: 2 additions & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
| cabal | | | | `haskell-language-server-wrapper` |
| cairo |||| `cairo-language-server` |
| capnp || || |
| cel || | | |
| clojure || | | `clojure-lsp` |
| cmake |||| `cmake-language-server` |
| comment || | | |
Expand Down Expand Up @@ -154,6 +155,7 @@
| smithy || | | `cs` |
| sml || | | |
| solidity || | | `solc` |
| spicedb || | | |
| sql || | | |
| sshclientconfig || | | |
| starlark ||| | |
Expand Down
24 changes: 24 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,30 @@ 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 = "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"
Expand Down
66 changes: 66 additions & 0 deletions runtime/queries/cel/highlights.scm
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions runtime/queries/spicedb/highlights.scm
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions runtime/queries/spicedb/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
((comment) @injection.content
(#set! injection.language "comment"))

((caveat_expr) @injection.content
(#set! injection.language "cel"))
4 changes: 4 additions & 0 deletions runtime/queries/spicedb/tags.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(object_definition
name: (type_identifier) @name) @definition.type

(type_identifier) @name @reference.type

0 comments on commit bb19f55

Please sign in to comment.