From 0d7e1dc93aabc9351ee30ceddda374ef5d42c685 Mon Sep 17 00:00:00 2001 From: Matouš Dzivjak Date: Thu, 19 Mar 2026 21:15:12 +0000 Subject: [PATCH] feat(languages): update fga to latest (#15473) Update tree-sitter-fga to latest and update highlight queries accordingly. --- languages.toml | 4 ++-- runtime/queries/fga/highlights.scm | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------ runtime/queries/fga/indents.scm | 1 + runtime/queries/fga/injections.scm | 2 ++ runtime/queries/fga/locals.scm | 16 ++++++++++++++++ runtime/queries/fga/textobjects.scm | 6 ++++++ 6 file(s) changed, 86 insertion(s)(+), 86 deletion(s)(-) diff --git a/languages.toml b/languages.toml --- a/languages.toml +++ b/languages.toml @@ -4787,13 +4787,13 @@ name = "fga" scope = "source.fga" injection-regex = "fga" -file-types = ["fga"] +file-types = ["fga", { glob = "fga.mod" } ] comment-token = "#" indent = { tab-width = 2, unit = " " } [[grammar]] name = "fga" -source = { git = "https://github.com/matoous/tree-sitter-fga", rev = "5005e8dd976e1f67beb3d23204580eb6f8b4c965" } +source = { git = "https://github.com/matoous/tree-sitter-fga", rev = "ce72d1c484ba133a18e966d67be66bce85695451" } [[language]] name = "csv" diff --git a/runtime/queries/fga/highlights.scm b/runtime/queries/fga/highlights.scm --- a/runtime/queries/fga/highlights.scm +++ b/runtime/queries/fga/highlights.scm @@ -1,97 +1,72 @@ -; 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)) +(condition_declaration + (param + name: (identifier) @variable.parameter)) -(binary_expression (identifier) @variable) +(conditional + condition: (identifier) @function) -((type_identifier) @type.builtin - (#any-of? @type.builtin "string" "int" "map" "uint" "list" "timestamp" "bool" "duration" "double" "ipaddress")) +(type_declaration + name: (extended_identifier) @type) +(definition + relation: (extended_identifier) @variable) -; Operators +(indirect_relation + relation: (extended_identifier) @variable.other.member + tupleset: (extended_identifier) @variable) -[ - "!=" - "%" - "&" - "&&" - "&^" - "*" - "+" - "-" - "/" - "<" - "<<" - "<=" - "==" - ">" - ">=" - ">>" - "^" - "|" - "||" -] @operator +(relation_ref) @type +(all) @type -[ - "or" - "and" - "but not" - "from" - "with" -] @keyword.operator +((simple_type_identifier) @type.builtin) -; Keywords - -[ - "model" - "schema" - "type" - "relations" - "define" -] @keyword - -[ - "condition" -] @keyword.function - -; Misc +((container_type_identifier) @type.builtin) (version) @constant.numeric +(int) @constant.numeric.integer +(uint) @constant.numeric.integer +(float) @constant.numeric.float + +(string) @string +(bytes) @string.special + +(boolean) @constant.builtin.boolean +(null) @constant.builtin + +(condition_body + (identifier) @variable) + +(parenthesized_condition + (identifier) @variable) + +(bracket_condition + (identifier) @variable) + +(braced_condition + (identifier) @variable) + +(operator) @operator +(condition_operator) @operator + +(condition_body ["{" "}"] @punctuation.bracket) +(parenthesized_condition ["(" ")"] @punctuation.bracket) +(bracket_condition ["[" "]"] @punctuation.bracket) +(braced_condition ["{" "}"] @punctuation.bracket) + +(model) @keyword +(module "module" @keyword) +(schema "schema" @keyword) +(contents "contents" @keyword) +(relations "relations" @keyword) +(type_declaration "extend" @keyword) +(type_declaration "type" @keyword) +(definition "define" @keyword) + +(indirect_relation "from" @keyword.operator) +(conditional "with" @keyword.operator) +(condition_declaration "condition" @keyword.function) + (comment) @comment diff --git a/runtime/queries/fga/indents.scm b/runtime/queries/fga/indents.scm --- a/runtime/queries/fga/indents.scm +++ b/runtime/queries/fga/indents.scm @@ -1,5 +1,6 @@ [ (source_file) + (contents) (type_declaration) (relations) (condition_declaration) diff --git a/runtime/queries/fga/injections.scm b/runtime/queries/fga/injections.scm new file mode 100644 --- /dev/null +++ b/runtime/queries/fga/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/fga/locals.scm b/runtime/queries/fga/locals.scm new file mode 100644 --- /dev/null +++ b/runtime/queries/fga/locals.scm @@ -0,0 +1,16 @@ +(condition_declaration) @local.scope + +(param + name: (identifier) @local.definition.variable.parameter) + +(condition_body + (identifier) @local.reference) + +(parenthesized_condition + (identifier) @local.reference) + +(bracket_condition + (identifier) @local.reference) + +(braced_condition + (identifier) @local.reference) diff --git a/runtime/queries/fga/textobjects.scm b/runtime/queries/fga/textobjects.scm --- a/runtime/queries/fga/textobjects.scm +++ b/runtime/queries/fga/textobjects.scm @@ -1,5 +1,11 @@ +(type_declaration + (relations) @class.inside) @class.around + (condition_declaration body: (_) @function.inside) @function.around + +(relations + (definition) @entry.inside) @entry.around (param ((_) @parameter.inside . ","? @parameter.around) @parameter.around) -- tangled.sh