logiguard fork: GPUI xdg-activation keyboard-focus serial fix
Some checks failed
Update All Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Triage Project Sync (#84) / Sync triage project (push) Has been cancelled
release_nightly / notify_on_failure (push) Has been cancelled
release_nightly / check_style (push) Has been cancelled
release_nightly / run_tests_windows (push) Has been cancelled
release_nightly / clippy_windows (push) Has been cancelled
release_nightly / bundle_linux_aarch64 (push) Has been cancelled
release_nightly / bundle_linux_x86_64 (push) Has been cancelled
release_nightly / bundle_mac_aarch64 (push) Has been cancelled
release_nightly / bundle_mac_x86_64 (push) Has been cancelled
release_nightly / bundle_windows_aarch64 (push) Has been cancelled
release_nightly / bundle_windows_x86_64 (push) Has been cancelled
release_nightly / build_nix_linux_x86_64 (push) Has been cancelled
release_nightly / build_nix_mac_aarch64 (push) Has been cancelled
release_nightly / update_nightly_tag (push) Has been cancelled
Hotfix Review Monitor / check-hotfix-reviews (push) Has been cancelled
Stale PR Review Reminder / check-stale-prs (push) Has been cancelled
Update Weekly Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Bump collab-staging Tag / update-collab-staging-tag (push) Has been cancelled
compliance_check / scheduled_compliance_check (push) Has been cancelled

Single-commit orphan branch: full zed-industries/zed @ 8c74db0 source tree
with a 3-file patch applied (no upstream history).

Patch (crates/gpui_linux/src/linux/wayland/):
  - serial.rs: add SerialKind::KeyboardEnter
  - client.rs: store wl_keyboard.enter serial; add latest_serial_of()
  - window.rs: activate() uses keyboard-enter serial (Mutter focus gate)

Mutter honors window activation only when the token carries the keyboard-
focus serial from wl_keyboard.enter; GPUI used a stale mouse-press serial.
See docs/tray-window-focus-wayland.md in logiguard.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Mohamad Khani
2026-07-14 02:22:17 +03:30
commit b72a46db68
3984 changed files with 1583326 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
[package]
name = "zed_proto"
version = "0.3.2"
edition.workspace = true
publish.workspace = true
license = "Apache-2.0"
[lints]
workspace = true
[lib]
path = "src/proto.rs"
crate-type = ["cdylib"]
[dependencies]
zed_extension_api = "0.7.0"

View File

@@ -0,0 +1 @@
../../LICENSE-APACHE

View File

@@ -0,0 +1,24 @@
id = "proto"
name = "Proto"
description = "Protocol Buffers support."
version = "0.3.2"
schema_version = 1
authors = ["Zed Industries <support@zed.dev>"]
repository = "https://github.com/zed-industries/zed"
[grammars.proto]
repository = "https://github.com/coder3101/tree-sitter-proto"
commit = "a6caac94b5aa36b322b5b70040d5b67132f109d0"
[language_servers.buf]
name = "Buf"
languages = ["Proto"]
[language_servers.protobuf-language-server]
name = "Protobuf Language Server"
languages = ["Proto"]
[language_servers.protols]
name = "Protols"
languages = ["Proto"]

View File

@@ -0,0 +1,13 @@
name = "Proto"
grammar = "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"] },
]

View File

@@ -0,0 +1,62 @@
[
"syntax"
"package"
"option"
"optional"
"import"
"service"
"rpc"
"returns"
"message"
"enum"
"extend"
"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

View File

@@ -0,0 +1,11 @@
(_
"{"
"}" @end) @indent
(_
"["
"]" @end) @indent
(_
"("
")" @end) @indent

View File

@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))

View File

@@ -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

View File

@@ -0,0 +1,22 @@
(message
(message_body
"{"
(_)* @class.inside
"}")) @class.around
(enum
(enum_body
"{"
(_)* @class.inside
"}")) @class.around
(service
"service"
(_)
"{"
(_)* @class.inside
"}") @class.around
(rpc) @function.around
(comment)+ @comment.around

View File

@@ -0,0 +1,8 @@
mod buf;
mod protobuf_language_server;
mod protols;
mod util;
pub(crate) use buf::*;
pub(crate) use protobuf_language_server::*;
pub(crate) use protols::*;

View File

@@ -0,0 +1,114 @@
use std::fs;
use zed_extension_api::{
self as zed, Architecture, DownloadedFileType, GithubReleaseOptions, Os, Result,
settings::LspSettings,
};
use crate::language_servers::util;
pub(crate) struct BufLsp {
cached_binary_path: Option<String>,
}
impl BufLsp {
pub(crate) const SERVER_NAME: &str = "buf";
pub(crate) fn new() -> Self {
BufLsp {
cached_binary_path: None,
}
}
pub(crate) fn language_server_binary(
&mut self,
worktree: &zed::Worktree,
) -> Result<zed::Command> {
let binary_settings = LspSettings::for_worktree(Self::SERVER_NAME, worktree)
.ok()
.and_then(|lsp_settings| lsp_settings.binary);
let args = binary_settings
.as_ref()
.and_then(|binary_settings| binary_settings.arguments.clone())
.unwrap_or_else(|| ["lsp", "serve"].map(ToOwned::to_owned).into());
if let Some(path) = binary_settings.and_then(|binary_settings| binary_settings.path) {
return Ok(zed::Command {
command: path,
args,
env: Default::default(),
});
} else if let Some(path) = self.cached_binary_path.clone() {
return Ok(zed::Command {
command: path,
args,
env: Default::default(),
});
} else if let Some(path) = worktree.which(Self::SERVER_NAME) {
self.cached_binary_path = Some(path.clone());
return Ok(zed::Command {
command: path,
args,
env: Default::default(),
});
}
let latest_release = zed::latest_github_release(
"bufbuild/buf",
GithubReleaseOptions {
require_assets: true,
pre_release: false,
},
)?;
let (os, arch) = zed::current_platform();
let release_suffix = match (os, arch) {
(Os::Mac, Architecture::Aarch64) => "Darwin-arm64",
(Os::Mac, Architecture::X8664) => "Darwin-x86_64",
(Os::Linux, Architecture::Aarch64) => "Linux-aarch64",
(Os::Linux, Architecture::X8664) => "Linux-x86_64",
(Os::Windows, Architecture::Aarch64) => "Windows-arm64.exe",
(Os::Windows, Architecture::X8664) => "Windows-x86_64.exe",
_ => {
return Err("Platform and architecture not supported by buf CLI".to_string());
}
};
let release_name = format!("buf-{release_suffix}");
let version_dir = format!("{}-{}", Self::SERVER_NAME, latest_release.version);
fs::create_dir_all(&version_dir).map_err(|_| "Could not create directory")?;
let binary_path = format!("{version_dir}/buf");
let download_target = latest_release
.assets
.into_iter()
.find(|asset| asset.name == release_name)
.ok_or_else(|| {
format!(
"Could not find asset with name {} in buf CLI release",
&release_name
)
})?;
zed::download_file(
&download_target.download_url,
&binary_path,
DownloadedFileType::Uncompressed,
)?;
zed::make_file_executable(&binary_path)?;
util::remove_outdated_versions(Self::SERVER_NAME, &version_dir)?;
self.cached_binary_path = Some(binary_path.clone());
Ok(zed::Command {
command: binary_path,
args,
env: Default::default(),
})
}
}

View File

@@ -0,0 +1,52 @@
use zed_extension_api::{self as zed, Result, settings::LspSettings};
pub(crate) struct ProtobufLanguageServer {
cached_binary_path: Option<String>,
}
impl ProtobufLanguageServer {
pub(crate) const SERVER_NAME: &str = "protobuf-language-server";
pub(crate) fn new() -> Self {
ProtobufLanguageServer {
cached_binary_path: None,
}
}
pub(crate) fn language_server_binary(
&mut self,
worktree: &zed::Worktree,
) -> Result<zed::Command> {
let binary_settings = LspSettings::for_worktree(Self::SERVER_NAME, worktree)
.ok()
.and_then(|lsp_settings| lsp_settings.binary);
let args = binary_settings
.as_ref()
.and_then(|binary_settings| binary_settings.arguments.clone())
.unwrap_or_else(|| vec!["-logs".into(), "".into()]);
if let Some(path) = binary_settings.and_then(|binary_settings| binary_settings.path) {
Ok(zed::Command {
command: path,
args,
env: Default::default(),
})
} else if let Some(path) = self.cached_binary_path.clone() {
Ok(zed::Command {
command: path,
args,
env: Default::default(),
})
} else if let Some(path) = worktree.which(Self::SERVER_NAME) {
self.cached_binary_path = Some(path.clone());
Ok(zed::Command {
command: path,
args,
env: Default::default(),
})
} else {
Err(format!("{} not found in PATH", Self::SERVER_NAME))
}
}
}

View File

@@ -0,0 +1,113 @@
use zed_extension_api::{
self as zed, Architecture, DownloadedFileType, GithubReleaseOptions, Os, Result,
settings::LspSettings,
};
use crate::language_servers::util;
pub(crate) struct ProtoLs {
cached_binary_path: Option<String>,
}
impl ProtoLs {
pub(crate) const SERVER_NAME: &str = "protols";
pub(crate) fn new() -> Self {
ProtoLs {
cached_binary_path: None,
}
}
pub(crate) fn language_server_binary(
&mut self,
worktree: &zed::Worktree,
) -> Result<zed::Command> {
let binary_settings = LspSettings::for_worktree(Self::SERVER_NAME, worktree)
.ok()
.and_then(|lsp_settings| lsp_settings.binary);
let args = binary_settings
.as_ref()
.and_then(|binary_settings| binary_settings.arguments.clone())
.unwrap_or_default();
let env = worktree.shell_env();
if let Some(path) = binary_settings.and_then(|binary_settings| binary_settings.path) {
return Ok(zed::Command {
command: path,
args,
env,
});
} else if let Some(path) = self.cached_binary_path.clone() {
return Ok(zed::Command {
command: path,
args,
env,
});
} else if let Some(path) = worktree.which(Self::SERVER_NAME) {
self.cached_binary_path = Some(path.clone());
return Ok(zed::Command {
command: path,
args,
env,
});
}
let latest_release = zed::latest_github_release(
"coder3101/protols",
GithubReleaseOptions {
require_assets: true,
pre_release: false,
},
)?;
let (os, arch) = zed::current_platform();
let release_suffix = match (os, arch) {
(Os::Mac, Architecture::Aarch64) => "aarch64-apple-darwin.tar.gz",
(Os::Mac, Architecture::X8664) => "x86_64-apple-darwin.tar.gz",
(Os::Linux, Architecture::Aarch64) => "aarch64-unknown-linux-gnu.tar.gz",
(Os::Linux, Architecture::X8664) => "x86_64-unknown-linux-gnu.tar.gz",
(Os::Windows, Architecture::X8664) => "x86_64-pc-windows-msvc.zip",
_ => {
return Err("Platform and architecture not supported by Protols".to_string());
}
};
let release_name = format!("protols-{release_suffix}");
let file_type = if os == Os::Windows {
DownloadedFileType::Zip
} else {
DownloadedFileType::GzipTar
};
let version_dir = format!("{}-{}", Self::SERVER_NAME, latest_release.version);
let binary_path = format!("{version_dir}/protols");
let download_target = latest_release
.assets
.into_iter()
.find(|asset| asset.name == release_name)
.ok_or_else(|| {
format!(
"Could not find asset with name {} in Protols release",
&release_name
)
})?;
zed::download_file(&download_target.download_url, &version_dir, file_type)?;
zed::make_file_executable(&binary_path)?;
util::remove_outdated_versions(Self::SERVER_NAME, &version_dir)?;
self.cached_binary_path = Some(binary_path.clone());
Ok(zed::Command {
command: binary_path,
args,
env,
})
}
}

View File

@@ -0,0 +1,19 @@
use std::fs;
use zed_extension_api::Result;
pub(super) fn remove_outdated_versions(
language_server_id: &'static str,
version_dir: &str,
) -> Result<()> {
let entries = fs::read_dir(".").map_err(|e| format!("failed to list working directory {e}"))?;
for entry in entries {
let entry = entry.map_err(|e| format!("failed to load directory entry {e}"))?;
if entry.file_name().to_str().is_none_or(|file_name| {
file_name.starts_with(language_server_id) && file_name != version_dir
}) {
fs::remove_dir_all(entry.path()).ok();
}
}
Ok(())
}

View File

@@ -0,0 +1,66 @@
use zed_extension_api::{self as zed, Result, settings::LspSettings};
use crate::language_servers::{BufLsp, ProtoLs, ProtobufLanguageServer};
mod language_servers;
struct ProtobufExtension {
protobuf_language_server: Option<ProtobufLanguageServer>,
protols: Option<ProtoLs>,
buf_lsp: Option<BufLsp>,
}
impl zed::Extension for ProtobufExtension {
fn new() -> Self {
Self {
protobuf_language_server: None,
protols: None,
buf_lsp: None,
}
}
fn language_server_command(
&mut self,
language_server_id: &zed_extension_api::LanguageServerId,
worktree: &zed_extension_api::Worktree,
) -> zed_extension_api::Result<zed_extension_api::Command> {
match language_server_id.as_ref() {
ProtobufLanguageServer::SERVER_NAME => self
.protobuf_language_server
.get_or_insert_with(ProtobufLanguageServer::new)
.language_server_binary(worktree),
ProtoLs::SERVER_NAME => self
.protols
.get_or_insert_with(ProtoLs::new)
.language_server_binary(worktree),
BufLsp::SERVER_NAME => self
.buf_lsp
.get_or_insert_with(BufLsp::new)
.language_server_binary(worktree),
_ => Err(format!("Unknown language server ID {}", language_server_id)),
}
}
fn language_server_workspace_configuration(
&mut self,
server_id: &zed::LanguageServerId,
worktree: &zed::Worktree,
) -> Result<Option<zed::serde_json::Value>> {
LspSettings::for_worktree(server_id.as_ref(), worktree)
.map(|lsp_settings| lsp_settings.settings)
}
fn language_server_initialization_options(
&mut self,
server_id: &zed::LanguageServerId,
worktree: &zed::Worktree,
) -> Result<Option<zed_extension_api::serde_json::Value>> {
LspSettings::for_worktree(server_id.as_ref(), worktree)
.map(|lsp_settings| lsp_settings.initialization_options)
}
}
zed::register_extension!(ProtobufExtension);