Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Send editor information to copilot

Antonio Scandurra4c3d6c854afd
diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs
index 71843402a63..4b67bc16504 100644
--- a/crates/copilot/src/copilot.rs
+++ b/crates/copilot/src/copilot.rs
@@ -350,6 +350,19 @@ impl Copilot {
)
.detach();
+ server
+ .request::<request::SetEditorInfo>(request::SetEditorInfoParams {
+ editor_info: request::EditorInfo {
+ name: "zed".into(),
+ version: env!("CARGO_PKG_VERSION").into(),
+ },
+ editor_plugin_info: request::EditorPluginInfo {
+ name: "zed-copilot".into(),
+ version: "0.0.1".into(),
+ },
+ })
+ .await?;
+
anyhow::Ok((server, status))
};
diff --git a/crates/copilot/src/request.rs b/crates/copilot/src/request.rs
index 08173c413aa..0d43bb7debc 100644
--- a/crates/copilot/src/request.rs
+++ b/crates/copilot/src/request.rs
@@ -166,3 +166,32 @@ impl lsp::notification::Notification for StatusNotification {
type Params = StatusNotificationParams;
const METHOD: &'static str = "statusNotification";
}
+
+pub enum SetEditorInfo {}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SetEditorInfoParams {
+ pub editor_info: EditorInfo,
+ pub editor_plugin_info: EditorPluginInfo,
+}
+
+impl lsp::request::Request for SetEditorInfo {
+ type Params = SetEditorInfoParams;
+ type Result = String;
+ const METHOD: &'static str = "setEditorInfo";
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct EditorInfo {
+ pub name: String,
+ pub version: String,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct EditorPluginInfo {
+ pub name: String,
+ pub version: String,
+}