nvim-treesitter/runtime/queries/proto/highlights.scm
Stefan VanBuren fb60ea759a
feat(proto): sync highlights with upstream
Syncs with coder3101/tree-sitter-proto#22, which adjusts captures to
better align with nvim-treesitter conventions:

- Package idents use @module, extend/oneof idents use @type
- Adds map_field, oneof_field @property captures
- option/syntax/edition use @keyword.directive
- extend/extensions/oneof/service moved to @keyword.type
- key_type/type use @type.builtin; rpc_name uses @function.method
- Import paths use @string.special.path
- proto2/proto3 syntax strings use @string.special.symbol
- Simplifies comment captures (removes doc comment distinction)

Honestly not sure how well other tree-sitter clients handle the
nvim-specific highlights, but I figure this is the primary client I'm
(at least personally) concerned about.
2026-03-16 10:51:28 -04:00

141 lines
1.4 KiB
Scheme

(package
(full_ident
(identifier) @module))
(extend
(full_ident
(identifier) @type))
(constant
(full_ident
(identifier) @constant))
(field
(identifier) @property)
(map_field
(identifier) @property)
(oneof
(identifier) @type)
(oneof_field
(identifier) @property)
(field_option
(identifier) @property)
(enum_value_option
(identifier) @property)
(block_lit
(identifier) @property)
[
"option"
"syntax"
"edition"
] @keyword.directive
[
"reserved"
"to"
"max"
] @keyword
[
"enum"
"extend"
"extensions"
"group"
"message"
"map"
"oneof"
"service"
] @keyword.type
"rpc" @keyword.function
"returns" @keyword.return
[
"export"
"local"
"optional"
"repeated"
"required"
"stream"
"weak"
"public"
] @keyword.modifier
[
"package"
"import"
] @keyword.import
[
(key_type)
(type)
] @type.builtin
[
(message_name)
(enum_name)
(service_name)
(message_or_enum_type)
] @type
(rpc_name) @function.method
(enum_field
(identifier) @constant)
(string) @string
(import
path: (string) @string.special.path)
[
"\"proto3\""
"\"proto2\""
] @string.special.symbol
(escape_sequence) @string.escape
(int_lit) @number
(float_lit) @number.float
[
(true)
(false)
] @boolean
(comment) @spell
(comment) @comment
[
"("
")"
"["
"]"
"{"
"}"
"<"
">"
] @punctuation.bracket
[
";"
","
"."
":"
] @punctuation.delimiter
[
"="
"-"
"+"
] @operator