Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml12
-rw-r--r--runtime/queries/fga/highlights.scm97
-rw-r--r--runtime/queries/fga/indents.scm8
-rw-r--r--runtime/queries/fga/textobjects.scm9
5 files changed, 127 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 9ecf7e70..b97a1f41 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -55,6 +55,7 @@
| erb | ✓ | | | |
| erlang | ✓ | ✓ | | `erlang_ls`, `elp` |
| esdl | ✓ | | | |
+| fga | ✓ | ✓ | ✓ | |
| fidl | ✓ | | | |
| fish | ✓ | ✓ | ✓ | `fish-lsp` |
| forth | ✓ | | | `forth-lsp` |
diff --git a/languages.toml b/languages.toml
index 8ce53cfc..f99ef063 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4127,3 +4127,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" }
diff --git a/runtime/queries/fga/highlights.scm b/runtime/queries/fga/highlights.scm
new file mode 100644
index 00000000..402f6f4d
--- /dev/null
+++ b/runtime/queries/fga/highlights.scm
@@ -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
diff --git a/runtime/queries/fga/indents.scm b/runtime/queries/fga/indents.scm
new file mode 100644
index 00000000..a75c3761
--- /dev/null
+++ b/runtime/queries/fga/indents.scm
@@ -0,0 +1,8 @@
+[
+ (source_file)
+ (type_declaration)
+ (relations)
+ (condition_declaration)
+] @indent
+
+"}" @outdent
diff --git a/runtime/queries/fga/textobjects.scm b/runtime/queries/fga/textobjects.scm
new file mode 100644
index 00000000..eddaa614
--- /dev/null
+++ b/runtime/queries/fga/textobjects.scm
@@ -0,0 +1,9 @@
+(condition_declaration
+ body: (_) @function.inside) @function.around
+
+(param
+ ((_) @parameter.inside . ","? @parameter.around) @parameter.around)
+
+(comment) @comment.inside
+
+(comment)+ @comment.around