From 3fd7ca334eb53c2f452717c632ea36ce95191390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20D=C3=B6rner?= Date: Wed, 20 Nov 2024 22:57:30 +0100 Subject: [PATCH] Add support for textproto language. (#11874) --- book/src/generated/lang-support.md | 1 + languages.toml | 13 +++++++++++++ runtime/queries/textproto/highlights.scm | 22 ++++++++++++++++++++++ runtime/queries/textproto/indents.scm | 11 +++++++++++ runtime/queries/textproto/textobjects.scm | 12 ++++++++++++ 5 files changed, 59 insertions(+) create mode 100644 runtime/queries/textproto/highlights.scm create mode 100644 runtime/queries/textproto/indents.scm create mode 100644 runtime/queries/textproto/textobjects.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 09f15b374..9308bec88 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -204,6 +204,7 @@ | task | ✓ | | | | | tcl | ✓ | | ✓ | | | templ | ✓ | | | `templ` | +| textproto | ✓ | ✓ | ✓ | | | tfvars | ✓ | | ✓ | `terraform-ls` | | thrift | ✓ | | | | | todotxt | ✓ | | | | diff --git a/languages.toml b/languages.toml index f24c70d81..5ad48c0c8 100644 --- a/languages.toml +++ b/languages.toml @@ -344,6 +344,19 @@ indent = { tab-width = 2, unit = " " } name = "protobuf" source = { git = "https://github.com/yusdacra/tree-sitter-protobuf", rev = "19c211a01434d9f03efff99f85e19f967591b175"} +[[language]] +name = "textproto" +file-types = ["txtpb", "textpb", "textproto"] +comment-token = "#" +scope = "source.textproto" +indent = { tab-width = 2, unit = " " } +formatter = { command = "txtpbfmt" } +auto-format = true + +[[grammar]] +name = "textproto" +source = { git = "https://github.com/PorterAtGoogle/tree-sitter-textproto", rev = "568471b80fd8793d37ed01865d8c2208a9fefd1b"} + [[language]] name = "elixir" scope = "source.elixir" diff --git a/runtime/queries/textproto/highlights.scm b/runtime/queries/textproto/highlights.scm new file mode 100644 index 000000000..766897f44 --- /dev/null +++ b/runtime/queries/textproto/highlights.scm @@ -0,0 +1,22 @@ +(string) @string + +(field_name) @variable.other.member + +(comment) @comment + +(number) @constant.numeric +; covers e.g. booleans and "inf" +(scalar_value (identifier)) @constant +; Covers "-inf" +(scalar_value (signed_identifier)) @constant.numeric + +[ + (open_squiggly) + (close_squiggly) + (open_square) + (close_square) + (open_arrow) + (close_arrow) +] @punctuation.bracket + +"," @punctuation.delimiter diff --git a/runtime/queries/textproto/indents.scm b/runtime/queries/textproto/indents.scm new file mode 100644 index 000000000..ebea3ff39 --- /dev/null +++ b/runtime/queries/textproto/indents.scm @@ -0,0 +1,11 @@ +[ + (message_value) + (message_list) + (scalar_list) +] @indent + +[ + (close_arrow) + (close_square) + (close_squiggly) +] @outdent diff --git a/runtime/queries/textproto/textobjects.scm b/runtime/queries/textproto/textobjects.scm new file mode 100644 index 000000000..9cc428c6a --- /dev/null +++ b/runtime/queries/textproto/textobjects.scm @@ -0,0 +1,12 @@ +(message_field + (_) @entry.inside) @entry.around + +(scalar_field + (_) @entry.inside) @entry.around + +(message_list + (_) @entry.around) + +(scalar_list + (_) @entry.around) +