From 1d5e4f3aa1e2368ce29c53b48b5e53702b002052 Mon Sep 17 00:00:00 2001 From: francisco souza <108725+fsouza@users.noreply.github.com> Date: Tue, 26 Apr 2022 15:36:26 -0400 Subject: [PATCH] feat(proto): add parser Related to #2307. --- lua/nvim-treesitter/parsers.lua | 10 ++++++ queries/proto/folds.scm | 5 +++ queries/proto/highlights.scm | 62 +++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 queries/proto/folds.scm create mode 100644 queries/proto/highlights.scm diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 8682d48eb..4ac58758d 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1050,6 +1050,16 @@ list.m68k = { filetype = "asm68k", } +list.proto = { + install_info = { + url = "https://github.com/mitchellh/tree-sitter-proto", + branch = "main", + files = { "src/parser.c" }, + }, + maintainers = { "@fsouza" }, + filetype = "proto", +} + local M = { list = list, filetype_to_parsername = filetype_to_parsername, diff --git a/queries/proto/folds.scm b/queries/proto/folds.scm new file mode 100644 index 000000000..645ac1819 --- /dev/null +++ b/queries/proto/folds.scm @@ -0,0 +1,5 @@ +[ + (enum) + (message) + (service) +] @fold diff --git a/queries/proto/highlights.scm b/queries/proto/highlights.scm new file mode 100644 index 000000000..a859ef418 --- /dev/null +++ b/queries/proto/highlights.scm @@ -0,0 +1,62 @@ +[ + "syntax" + "package" + "option" + "import" + "service" + "rpc" + "returns" + "message" + "enum" + "oneof" + "repeated" + "reserved" + "to" +] @keyword + +[ + (key_type) + (type) + (message_name) + (enum_name) + (service_name) + (rpc_name) + (message_or_enum_type) +] @type + +(enum_field + (identifier) @constant) + +[ + (string) + "\"proto3\"" +] @string + +(int_lit) @number + +(float_lit) @float + +[ + (true) + (false) +] @boolean + +(comment) @comment + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +[ + ";" + "," +] @punctuation.delimiter + +"=" @operator