From a8d2b54e28b25cbea1a5fae312165f56674168de Mon Sep 17 00:00:00 2001 From: 巢鹏 Date: Thu, 22 Feb 2024 21:57:07 -0500 Subject: feat: add fidl parser --- lockfile.json | 3 ++ lua/nvim-treesitter/parsers.lua | 9 ++++++ queries/fidl/folds.scm | 6 ++++ queries/fidl/highlights.scm | 64 +++++++++++++++++++++++++++++++++++++++++ queries/fidl/injections.scm | 2 ++ 5 files changed, 84 insertions(+) create mode 100644 queries/fidl/folds.scm create mode 100644 queries/fidl/highlights.scm create mode 100644 queries/fidl/injections.scm diff --git a/lockfile.json b/lockfile.json index 8e909e250..5a2d278b5 100644 --- a/lockfile.json +++ b/lockfile.json @@ -164,6 +164,9 @@ "fennel": { "revision": "9265a7d635d2f82a10738b9ad65ba8dd8bd4a84a" }, + "fidl": { + "revision": "0e1180bb126f280711a62f2a21e3609923fd8b0c" + }, "firrtl": { "revision": "2b5adae629c8cba528c7b1e4aa67a8ae28934ea5" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 324529cad..bd647d595 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -535,6 +535,15 @@ list.fennel = { maintainers = { "@alexmozaidze" }, } +list.fidl = { + install_info = { + url = "https://github.com/google/tree-sitter-fidl", + files = { "src/parser.c" }, + requires_generate_from_grammar = true, + }, + maintainers = { "@chaopeng" }, +} + list.firrtl = { install_info = { url = "https://github.com/amaanq/tree-sitter-firrtl", diff --git a/queries/fidl/folds.scm b/queries/fidl/folds.scm new file mode 100644 index 000000000..f524c455b --- /dev/null +++ b/queries/fidl/folds.scm @@ -0,0 +1,6 @@ +[ + (layout_declaration) + (protocol_declaration) + (resource_declaration) + (service_declaration) +] @fold diff --git a/queries/fidl/highlights.scm b/queries/fidl/highlights.scm new file mode 100644 index 000000000..ce7727010 --- /dev/null +++ b/queries/fidl/highlights.scm @@ -0,0 +1,64 @@ +[ + "ajar" + "alias" + "as" + "bits" + "closed" + "compose" + "const" + "enum" + "error" + "flexible" + "library" + "open" + ; "optional" we did not specify a node for optional yet + "overlay" + "protocol" + "reserved" + "resource" + "service" + "strict" + "struct" + "table" + "type" + "union" + "using" +] @keyword + +(primitives_type) @type.builtin + +(builtin_complex_type) @type.builtin + +(const_declaration + (identifier) @constant) + +[ + "=" + "|" + "&" + "->" +] @operator + +(attribute + "@" @attribute + (identifier) @attribute) + +(string_literal) @string + +(numeric_literal) @number + +[ + (true) + (false) +] @boolean + +(comment) @comment + +[ + "(" + ")" + "<" + ">" + "{" + "}" +] @punctuation.bracket diff --git a/queries/fidl/injections.scm b/queries/fidl/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/queries/fidl/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) -- cgit v1.2.3-70-g09d2