Skip to content

Commit

Permalink
Add protobuf support (zed-industries#6748)
Browse files Browse the repository at this point in the history
Release Notes:

- Added protobuf syntax highlighting
([#5160](https://github.com/zed-industries/zed/issues/5160)).
  • Loading branch information
MordFustang21 authored Jan 30, 2024
1 parent dfbcaf3 commit 7bfa584
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ tree-sitter-json = { git = "https://github.com/tree-sitter/tree-sitter-json", re
tree-sitter-rust = "0.20.3"
tree-sitter-markdown = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "330ecab87a3e3a7211ac69bbadc19eabecdb1cca" }
tree-sitter-php = "0.21.1"
tree-sitter-proto = {git = "https://github.com/rewinfrey/tree-sitter-proto", rev = "36d54f288aee112f13a67b550ad32634d0c2cb52"}
tree-sitter-purescript = { git = "https://github.com/ivanmoreau/tree-sitter-purescript", rev = "a37140f0c7034977b90faa73c94fcb8a5e45ed08" }
tree-sitter-python = "0.20.2"
tree-sitter-toml = { git = "https://github.com/tree-sitter/tree-sitter-toml", rev = "342d9be207c2dba869b9967124c679b5e6fd0ebe" }
Expand Down
1 change: 1 addition & 0 deletions crates/zed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ tree-sitter-heex.workspace = true
tree-sitter-json.workspace = true
tree-sitter-rust.workspace = true
tree-sitter-markdown.workspace = true
tree-sitter-proto.workspace = true
tree-sitter-python.workspace = true
tree-sitter-toml.workspace = true
tree-sitter-typescript.workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/zed/src/languages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ pub fn init(
tree_sitter_uiua::language(),
vec![Arc::new(uiua::UiuaLanguageServer {})],
);
language("proto", tree_sitter_proto::language(), vec![]);

if let Ok(children) = std::fs::read_dir(&*PLUGINS_DIR) {
for child in children {
Expand Down
12 changes: 12 additions & 0 deletions crates/zed/src/languages/proto/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name = "proto"
path_suffixes = ["proto"]
line_comments = ["// "]
autoclose_before = ";:.,=}])>"
brackets = [
{ start = "{", end = "}", close = true, newline = true },
{ start = "[", end = "]", close = true, newline = true },
{ start = "(", end = ")", close = true, newline = true },
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["comment", "string"] },
{ start = "'", end = "'", close = true, newline = false, not_in = ["comment", "string"] },
{ start = "/*", end = " */", close = true, newline = false, not_in = ["comment", "string"] },
]
61 changes: 61 additions & 0 deletions crates/zed/src/languages/proto/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[
"syntax"
"package"
"option"
"optional"
"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

[
(true)
(false)
] @boolean

(comment) @comment

[
"("
")"
"["
"]"
"{"
"}"
"<"
">"
] @punctuation.bracket

[
";"
","
] @punctuation.delimiter

"=" @operator
19 changes: 19 additions & 0 deletions crates/zed/src/languages/proto/outline.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(message
"message" @context
(message_name
(identifier) @name)) @item

(service
"service" @context
(service_name
(identifier) @name)) @item

(rpc
"rpc" @context
(rpc_name
(identifier) @name)) @item

(enum
"enum" @context
(enum_name
(identifier) @name)) @item
4 changes: 4 additions & 0 deletions docs/src/languages/proto.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Proto

- Tree-Sitter: [tree-sitter-proto](https://github.com/rewinfrey/tree-sitter-proto)
- Language-Server: N/A

0 comments on commit 7bfa584

Please sign in to comment.