From 5ca72f9b308e1f44dbcb9d7656a5eb6c47b2c7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matou=C5=A1=20Dzivjak?= Date: Tue, 8 Jul 2025 09:07:51 +0200 Subject: [PATCH] feat(fga): add FGA grammar FGA is the DSL for [OpenFGA](https://openfga.dev/) authorization models - a zanzibar-like Role-Based Access Control system. --- SUPPORTED_LANGUAGES.md | 1 + lua/nvim-treesitter/parsers.lua | 8 +++++ runtime/queries/fga/highlights.scm | 50 ++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 runtime/queries/fga/highlights.scm diff --git a/SUPPORTED_LANGUAGES.md b/SUPPORTED_LANGUAGES.md index a3aabea78..a43a837d1 100644 --- a/SUPPORTED_LANGUAGES.md +++ b/SUPPORTED_LANGUAGES.md @@ -80,6 +80,7 @@ ecma (queries only)[^ecma] | unstable | `HFIJL` | | @steelsojka [facility](https://github.com/FacilityApi/tree-sitter-facility) | unstable | `HFIJ ` | | @bryankenote [faust](https://github.com/khiner/tree-sitter-faust) | unstable | `H  J ` | | @khiner [fennel](https://github.com/alexmozaidze/tree-sitter-fennel) | unstable | `HF JL` | | @alexmozaidze +[fga](https://github.com/matoous/tree-sitter-fga) | unstable | `H    ` | | @matoous [fidl](https://github.com/google/tree-sitter-fidl) | unstable | `HF J ` | | @chaopeng [firrtl](https://github.com/tree-sitter-grammars/tree-sitter-firrtl) | unstable | `HFIJL` | | @amaanq [fish](https://github.com/ram02z/tree-sitter-fish) | unstable | `HFIJL` | | @ram02z diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index cf9368840..350907570 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -550,6 +550,14 @@ return { maintainers = { '@alexmozaidze' }, tier = 2, }, + fga = { + install_info = { + revision = '44bfe4e15dc11969f1a23e5f0fa9d8e961268721', + url = 'https://github.com/matoous/tree-sitter-fga', + }, + maintainers = { '@matoous' }, + tier = 2, + }, fidl = { install_info = { revision = '0a8910f293268e27ff554357c229ba172b0eaed2', diff --git a/runtime/queries/fga/highlights.scm b/runtime/queries/fga/highlights.scm new file mode 100644 index 000000000..e420c6c9d --- /dev/null +++ b/runtime/queries/fga/highlights.scm @@ -0,0 +1,50 @@ +(call_expression + function: (identifier) @function) + +(call_expression + function: (selector_expression + field: (identifier) @function.method)) + +((type_identifier) @type.builtin + (#match? @type.builtin "^(string|int|map|uint|list|timestamp|bool|duration|double|ipaddress)$")) + +(condition_declaration + name: (identifier) @function) + +(version) @number + +[ + "*" + "/" + "%" + ">>" + "<<" + "&" + "&^" +] @operator + +[ + "+" + "-" + "|" + "^" +] @operator + +[ + "or" + "and" + "but not" +] @operator + +[ + "model" + "schema" + "type" + "relations" + "define" + "from" +] @keyword + +"condition" @keyword.function + +(comment) @comment