Skip to content

Commit

Permalink
add support for the FGA language (helix-editor#12763)
Browse files Browse the repository at this point in the history
  • Loading branch information
drewzemke authored and nik-rev committed Feb 6, 2025
1 parent 5bdf246 commit fa9d2bc
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 0 deletions.
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
| erb || | | |
| erlang ||| | `erlang_ls`, `elp` |
| esdl || | | |
| fga |||| |
| fidl || | | |
| fish |||| `fish-lsp` |
| forth || | | `forth-lsp` |
Expand Down
12 changes: 12 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4136,3 +4136,15 @@ indent = { tab-width = 4, unit = " " }
[[grammar]]
name = "tera"
source = { git = "https://github.com/uncenter/tree-sitter-tera", rev = "e8d679a29c03e64656463a892a30da626e19ed8e" }

[[language]]
name = "fga"
scope = "source.fga"
injection-regex = "fga"
file-types = ["fga"]
comment-token = "#"
indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "fga"
source = { git = "https://github.com/matoous/tree-sitter-fga", rev = "5005e8dd976e1f67beb3d23204580eb6f8b4c965" }
97 changes: 97 additions & 0 deletions runtime/queries/fga/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
; Expressions

(call_expression
function: (identifier) @function)

(call_expression
function: (selector_expression
field: (identifier) @function.method))


; Type Definitions

(type_declaration (identifier) @type)

(definition
relation: (identifier) @variable)


; Relation Definitions

(relation_def (identifier) @variable.other.member)

(direct_relationship (identifier) @type)
(direct_relationship (conditional (identifier) @function))

(relation_ref
. (identifier) @type
(identifier) @variable.other.member)

(indirect_relation
. (identifier) @variable.other.member
(identifier) @variable)


; Condition Defintions

(condition_declaration
name: (identifier) @function)

(condition_declaration (param (identifier) @variable.parameter))

(binary_expression (identifier) @variable)

((type_identifier) @type.builtin
(#any-of? @type.builtin "string" "int" "map" "uint" "list" "timestamp" "bool" "duration" "double" "ipaddress"))


; Operators

[
"!="
"%"
"&"
"&&"
"&^"
"*"
"+"
"-"
"/"
"<"
"<<"
"<="
"=="
">"
">="
">>"
"^"
"|"
"||"
] @operator

[
"or"
"and"
"but not"
"from"
"with"
] @keyword.operator

; Keywords

[
"model"
"schema"
"type"
"relations"
"define"
] @keyword

[
"condition"
] @keyword.function

; Misc

(version) @constant.numeric
(comment) @comment
8 changes: 8 additions & 0 deletions runtime/queries/fga/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
(source_file)
(type_declaration)
(relations)
(condition_declaration)
] @indent

"}" @outdent
9 changes: 9 additions & 0 deletions runtime/queries/fga/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(condition_declaration
body: (_) @function.inside) @function.around

(param
((_) @parameter.inside . ","? @parameter.around) @parameter.around)

(comment) @comment.inside

(comment)+ @comment.around

0 comments on commit fa9d2bc

Please sign in to comment.