From 6d19e848614169fd509e16951061727dad0b5d72 Mon Sep 17 00:00:00 2001 From: chaopeng Date: Sat, 24 Feb 2024 18:05:26 -0500 Subject: [PATCH] add fidl support --- book/src/generated/lang-support.md | 1 + languages.toml | 18 ++++++++ runtime/queries/fidl/folds.scm | 6 +++ runtime/queries/fidl/highlights.scm | 64 +++++++++++++++++++++++++++++ runtime/queries/fidl/injections.scm | 2 + 5 files changed, 91 insertions(+) create mode 100644 runtime/queries/fidl/folds.scm create mode 100644 runtime/queries/fidl/highlights.scm create mode 100644 runtime/queries/fidl/injections.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 7aec37778080..1bc6b0817036 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -44,6 +44,7 @@ | erb | ✓ | | | | | erlang | ✓ | ✓ | | `erlang_ls` | | esdl | ✓ | | | | +| fidl | ✓ | | | | | fish | ✓ | ✓ | ✓ | | | forth | ✓ | | | `forth-lsp` | | fortran | ✓ | | ✓ | `fortls` | diff --git a/languages.toml b/languages.toml index 112333ea91e1..9208acfd362d 100644 --- a/languages.toml +++ b/languages.toml @@ -3140,3 +3140,21 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "groovy" source = { git = "https://github.com/Decodetalkers/tree-sitter-groovy", rev = "7e023227f46fee428b16a0288eeb0f65ee2523ec" } + +[[language]] +name = "fidl" +scope = "source.fidl" +injection-regex = "fidl" +file-types = ["fidl"] +comment-token = "//" +indent = { tab-width = 4, unit = " " } + +[language.auto-pairs] +'"' = '"' +'{' = '}' +'(' = ')' +'<' = '>' + +[[grammar]] +name = "fidl" +source = { git = "https://github.com/google/tree-sitter-fidl", rev = "bdbb635a7f5035e424f6173f2f11b9cd79703f8d" } diff --git a/runtime/queries/fidl/folds.scm b/runtime/queries/fidl/folds.scm new file mode 100644 index 000000000000..f524c455b4bb --- /dev/null +++ b/runtime/queries/fidl/folds.scm @@ -0,0 +1,6 @@ +[ + (layout_declaration) + (protocol_declaration) + (resource_declaration) + (service_declaration) +] @fold diff --git a/runtime/queries/fidl/highlights.scm b/runtime/queries/fidl/highlights.scm new file mode 100644 index 000000000000..c70d22198b74 --- /dev/null +++ b/runtime/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) @constant.numeric + +[ + (true) + (false) +] @constant.builtin.boolean + +(comment) @comment + +[ + "(" + ")" + "<" + ">" + "{" + "}" +] @punctuation.bracket diff --git a/runtime/queries/fidl/injections.scm b/runtime/queries/fidl/injections.scm new file mode 100644 index 000000000000..2f0e58eb6431 --- /dev/null +++ b/runtime/queries/fidl/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment"))