{ // ── 项目级 Zed 配置: rust-analyzer 性能极限优化 ────────────── // // workspace: src-tauri + 7 个 df-* crate 的 Rust Monorepo // flcheck 单次 600+ 行 artifact JSON → Zed 解析+渲染冻结 UI // 核心策略: 关保存即 check · 限制检查范围 · 裁切 LSP 负载 · 排 IO 争抢 // ───────────────────────────────────────────────────────────────── "lsp": { "rust-analyzer": { "initialization_options": { // ── cargo 编译参数 ─────────────────────────────────── "cargo": { "features": [], "allTargets": false, // 只为 host target 解析 "noDefaultFeatures": false, "targetDir": null, "buildScripts": { "enable": true, "invocationStrategy": "once", // 只跑一次,不反复 "rerun": "on-save" }, "extraArgs": [] }, // ── check / flycheck ──────────────────────────────── "check": { "onSave": false, // ★ 核心!关保存即 check "workspace": false, // 手动 check 也只查当前 crate "command": "check", // 用 check,非 clippy "invocationStrategy": "once", // 只跑一轮,不反复 "features": [], "allTargets": false, "ignore": [ // 跳过不常用的目录 "benches", "examples", "xtask", "tests" ] }, // ── 缓存预热(关掉,省首次启动 CPU 爆发) ────────────── "cachePriming": { "enable": false }, // ── 诊断 ──────────────────────────────────────────── "diagnostics": { "enable": true, "experimental": { "enable": false }, "disabled": [ // 关掉非关键诊断,降 CPU "unresolved-proc-macro", "inactive-code", "macro-error" ] }, // ── proc-macro(必须开,否则 tauri 全报红) ──────────── "procMacro": { "enable": true, "attributes": { "enable": true } }, // ── 符号检索 ──────────────────────────────────────── "workspace": { "symbol": { "search": { "kind": "only_types", "limit": 64 } } }, // ── 补全(限流减少 LSP 计算量) ────────────────────── "completion": { "autoclose": true, "autoimport": { "enable": true }, "callable": { "snippets": "fill_arguments" }, "fullFunction": { "enable": false }, "limit": 200, // 补全条目上限 "postfix": { "enable": false // 关 postfix snippet 减少候选 } }, // ── 内联提示(大文件里关掉多数减少 UI 重绘) ────────── "inlayHints": { "bindingModeHints": { "enable": false }, "chainingHints": { "enable": false }, "closingBraceHints": { "enable": false }, "closureReturnTypeHints": { "enable": "never" }, "constructorHints": "never", "discriminantHints": { "enable": "never" }, "expressionAdjustmentHints": { "mode": "never" }, "implicitDrops": "never", "lifetimeElisionHints": { "enable": "skip_trivial" }, "maxLength": 100, "parameterHints": { "enable": true }, "reborrowHints": { "enable": "never" }, "renderColons": true, "typeHints": { "enable": true, "hideNamedConstructor": false } }, // ── 语义高亮(大文件关掉字符串部分减少重绘) ────────── "semanticHighlights": { "strings": { "enable": false } }, // ── 高亮关联(关掉减少 LSP 图构建) ────────────────── "highlightRelated": { "references": { "enable": false } }, // ── 测试解释器(关掉) ─────────────────────────────── "interpret": { "tests": false }, // ── rust-analyzer 文件扫描排除 ───────────────────── "files": { "excludeDirs": [ ".cargo", "target", "target-musl", "node_modules", "dist", ".zed", ".git" ] } } } }, // ── Zed 文件监视排除(减少 File Watcher IO 争抢) ──────────── // 和全局 ~/.config/zed/settings.json 的 file_scan_exclusions 叠加 "file_scan_exclusions": [ "**/target/**", "**/target-musl/**", "**/node_modules/**", "**/dist/**", "**/.cargo/**", "**/.git/**", "**/build/**" ] }