From 42efb31bbfc46bc4c17b8caded6fa2561b5895f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=9D=E5=B0=98?= <237809796@qq.com> Date: Sat, 4 Jul 2026 00:53:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96:=20Zed=20=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=8D=A1=E6=AD=BB=E6=B2=BB=E7=90=86(musl=20=E9=9A=94=E7=A6=BB?= =?UTF-8?q?=20+=20rust-analyzer=20=E9=85=8D=E7=BD=AE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - musl 交叉编译: 文档化 CARGO_TARGET_DIR=target-musl 隔离方案, 删除现有 349M 产物 - gitignore: 新增 target-musl/ 规则 - .zed/settings.json: 新建项目级 rust-analyzer 配置 - 关闭 check.onSave (Zed 卡死主因: 每次保存触发全 workspace check) - check.workspace=false (即便手动也只查当前 crate) - cargo.allTargets=false (跳过 musl/交叉 target 解析) - files.excludeDirs 排除 target/node_modules 等 - 保留 procMacro/tauri-codegen enable (否则宏会报红) --- .cargo/config.toml | 7 +++++ .gitignore | 1 + .zed/settings.json | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 .zed/settings.json diff --git a/.cargo/config.toml b/.cargo/config.toml index b2cbd54..2685761 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,12 @@ # musl linux 交叉编译(Windows 主机无 cc/musl-gcc,用 rust-lld self-contained link) # df-relay 云端部署:本地交叉产 static linux binary → scp 测试机普通运行 +# +# ⚠️ 默认不要跑交叉编译,产物体积大且会污染 target/ 影响日常 build/rust-analyzer 性能。 +# 需要部署 df-relay 时再显式执行,并把产物隔离到独立 target dir: +# +# CARGO_TARGET_DIR=target-musl cargo build --release --target x86_64-unknown-linux-musl -p df-relay +# +# 这样 musl 产物落到 target-musl/(已 gitignore),与主 target/ 完全隔离。 [target.x86_64-unknown-linux-musl] linker = "rust-lld" rustflags = ["-C", "link-self-contained=y"] diff --git a/.gitignore b/.gitignore index ff77e95..ca1070a 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ unpackage/ # Rust / Cargo target/ +target-musl/ # df-relay 交叉编译产物隔离目录(见 .cargo/config.toml) !Cargo.lock # Tauri diff --git a/.zed/settings.json b/.zed/settings.json new file mode 100644 index 0000000..dcf0b43 --- /dev/null +++ b/.zed/settings.json @@ -0,0 +1,64 @@ +{ + // 项目级 Zed 配置:优化 rust-analyzer 性能 + // + // 背景:本 workspace 含 src-tauri + 7 个 df-* crate, + // flycheck 单次产出 600+ 行 artifact JSON,Zed 解析+渲染会冻结 UI。 + // 核心策略:关掉保存即 check、限定 check 范围、隔离 target 目录。 + + "lsp": { + "rust-analyzer": { + "initialization_options": { + "cargo": { + "features": [], // 不编 default features 之外的重头 + "allTargets": false, // 只为 host target 解析,跳过 musl/交叉 + "targetDir": null, // 留空用 cargo 默认,避免双写 + "buildScripts": { + "enable": true, + "rerun": "on-save" + } + }, + "check": { + "onSave": false, // ★ 关键!关闭保存即 check(Zed 卡死主因) + "workspace": false, // 即便手动 check 也只查当前 crate + "command": "check", // 用 cargo check(非 clippy),首次开销低 + "features": [], + "allTargets": false + }, + "diagnostics": { + "enable": true, // 保留 rust-analyzer 自身诊断 + "experimental": { + "enable": false + } + }, + "procMacro": { + "enable": true, // 必须开,否则 tauri::generate_context 等会报红 + "attributes": { + "enable": true + } + }, + "workspace": { + "symbol": { + "search": { + "kind": "only_types", + "limit": 64 + } + } + }, + "completion": { + "callable": { + "snippets": "fill_arguments" + }, + "fullFunction": { + "enable": false + } + }, + "interpret": { + "tests": false + }, + "files": { + "excludeDirs": [".cargo", "target", "target-musl", "node_modules", "dist", ".zed"] + } + } + } + } +}