Skip to content

Commit

Permalink
Migrate to an improved proto grammar (helix-editor#12225)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdoerner authored Dec 31, 2024
1 parent 4a59f68 commit b1759f9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 38 deletions.
7 changes: 4 additions & 3 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -340,16 +340,17 @@ source = { git = "https://github.com/Beaglefoot/tree-sitter-awk", rev = "a799bc5
[[language]]
name = "protobuf"
scope = "source.proto"
injection-regex = "protobuf"
injection-regex = "proto"
file-types = ["proto"]
language-servers = [ "bufls", "pbkit" ]
comment-token = "//"
block-comment-tokens = { start = "/*", end = "*/" }
indent = { tab-width = 2, unit = " " }
grammar = "proto"

[[grammar]]
name = "protobuf"
source = { git = "https://github.com/yusdacra/tree-sitter-protobuf", rev = "19c211a01434d9f03efff99f85e19f967591b175"}
name = "proto"
source = { git = "https://github.com/sdoerner/tree-sitter-proto", rev = "778ab6ed18a7fcf82c83805a87d63376c51e80bc"}

[[language]]
name = "textproto"
Expand Down
46 changes: 22 additions & 24 deletions runtime/queries/protobuf/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
[
"syntax"
"edition"
"package"
"option"
"import"
"service"
"rpc"
"returns"
"message"
"map"
"enum"
"oneof"
"repeated"
"optional"
"required"
"reserved"
"to"
"stream"
"extend"
"optional"
] @keyword

[
(keyType)
(key_type)
(type)
(message_or_enum_type)
] @type.builtin

[
(mapName)
(enumName)
(messageName)
(extendName)
(serviceName)
(rpcName)
(enum_name)
(message_name)
(service_name)
(rpc_name)
] @type

[
(fieldName)
(optionName)
(field_name)
(option_name)
] @variable.other.member
(enumVariantName) @type.enum.variant
(enum_variant_name) @type.enum.variant

(fullIdent) @namespace
(full_ident) @namespace

(intLit) @constant.numeric.integer
(floatLit) @constant.numeric.float
(boolLit) @constant.builtin.boolean
(strLit) @string
(int_lit) @constant.numeric.integer
(float_lit) @constant.numeric.float
(bool) @constant.builtin.boolean
(string) @string

(constant) @constant
(block_lit) @constant

(comment) @comment

Expand All @@ -55,12 +57,8 @@
"]"
"{"
"}"
] @punctuation.bracket
] @punctuation.bracket

[
"="
] @operator
"=" @operator

[
";"
] @punctuation.delimiter
";" @punctuation.delimiter
12 changes: 6 additions & 6 deletions runtime/queries/protobuf/indents.scm
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[
(messageBody)
(enumBody)
(oneofBody)
(serviceBody)
(rpcBody)
(msgLit)
(message_body)
(enum_body)
(oneof_body)
(service_body)
(rpc_body)
(block_lit)
] @indent

"}" @outdent
Expand Down
10 changes: 5 additions & 5 deletions runtime/queries/protobuf/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(message (messageBody) @class.inside) @class.around
(enum (enumBody) @class.inside) @class.around
(service (serviceBody) @class.inside) @class.around
(message (message_body) @class.inside) @class.around
(enum (enum_body) @class.inside) @class.around
(service (service_body) @class.inside) @class.around

(rpc (enumMessageType) @parameter.inside) @function.inside
(rpc (enumMessageType) @parameter.around) @function.around
(rpc (message_or_enum_type) @parameter.inside) @function.inside
(rpc (message_or_enum_type) @parameter.around) @function.around

(comment) @comment.inside
(comment)+ @comment.around

0 comments on commit b1759f9

Please sign in to comment.