From 4b45f27a13500bd5f85d11e2e3bcda49bfdd065c Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Wed, 18 Aug 2021 13:54:47 +0300 Subject: [PATCH] feat: add protobuf tree-sitter parser with highlighting queries --- .gitmodules | 4 ++ helix-syntax/languages/tree-sitter-protobuf | 1 + languages.toml | 10 ++++ runtime/queries/protobuf/highlights.scm | 60 +++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-protobuf create mode 100644 runtime/queries/protobuf/highlights.scm diff --git a/.gitmodules b/.gitmodules index a1c0589e..e750198a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -98,3 +98,7 @@ path = helix-syntax/languages/tree-sitter-ledger url = https://github.com/cbarrete/tree-sitter-ledger shallow = true +[submodule "helix-syntax/languages/tree-sitter-protobuf"] + path = helix-syntax/languages/tree-sitter-protobuf + url = https://github.com/yusdacra/tree-sitter-protobuf.git + shallow = true diff --git a/helix-syntax/languages/tree-sitter-protobuf b/helix-syntax/languages/tree-sitter-protobuf new file mode 160000 index 00000000..a835f256 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-protobuf @@ -0,0 +1 @@ +Subproject commit a835f2568a8a8cbb7d9c02f2e8bcf98efa745d4e diff --git a/languages.toml b/languages.toml index 480f2a3e..47155523 100644 --- a/languages.toml +++ b/languages.toml @@ -30,6 +30,16 @@ comment-token = "#" indent = { tab-width = 2, unit = " " } +[[language]] +name = "protobuf" +scope = "source.proto" +injection-regex = "protobuf" +file-types = ["proto"] +roots = [] +comment-token = "//" + +indent = { tab-width = 2, unit = " " } + [[language]] name = "elixir" scope = "source.elixir" diff --git a/runtime/queries/protobuf/highlights.scm b/runtime/queries/protobuf/highlights.scm new file mode 100644 index 00000000..4597dd5a --- /dev/null +++ b/runtime/queries/protobuf/highlights.scm @@ -0,0 +1,60 @@ +[ + "syntax" + "package" + "option" + "import" + "service" + "rpc" + "returns" + "message" + "enum" + "oneof" + "repeated" + "reserved" + "to" + "stream" + "extend" +] @keyword + +[ + (keyType) + (type) +] @type.builtin + +[ + (mapName) + (oneofName) + (enumName) + (messageName) + (extendName) + (serviceName) + (rpcName) +] @type + +[ + (fieldName) + (optionName) +] @property +(enumVariantName) @type.enum.variant + +(fullIdent) @namespace + +[ + (intLit) + (floatLit) +] @number +(boolLit) @constant.builtin +(strLit) @string + +(constant) @constant + +(comment) @comment + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket \ No newline at end of file