Repository navigation
refactor(lsp-engine): 索引排除改由语言服务器声明 indexingExclusions,Core 不再识别 rust-analyzer 和 gopls - #68
Merged
Merged
Conversation
…-analyzer 和 gopls LSP 引擎原来按 provider 是 rust 还是 go 决定把排除目录写进 rust-analyzer.files.exclude 还是 gopls.directoryFilters,以及怎样写。 现在语言服务器在清单里声明 indexingExclusions(section、entry、rootEntry、 default、pathSyntax),启动计划的 sessionPolicy 带上它,引擎只按声明把 排除目录追加进服务器读到的配置;没有声明的服务器配置不变。 - plugin-language-servers:新增 IndexingExclusions 及校验,挂在会话字段上 - plugin-server-policy:SessionPolicy 接受并复核 indexingExclusions - lsp-engine:scan_settings 去掉按语言的分支,改为按声明填充 - 契约:README、schema、fixture、invalid-manifests、languages 参考页、 能力对照和协议更新记录 Refs 1lck/Lithe-IDEA#1856
This was referenced Nov 16, 2026
xiaoyumuxi
marked this pull request as ready for review
November 16, 2026 11:25
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
#1856 要求把 Core 里剩下的 5 类语言专属默认值移出 Core。本 PR 只做第 2 项(rust-analyzer / gopls 的索引排除)。第 5 项在 #66;第 1、3、4 项(忽略目录、go/node 运行时、运行发现)不在本 PR,#1856 保持打开。
PR 类型 / Type
改动说明 / What changes
背景 / Why
用户把目录排除在索引之外(或打开“排除 Git 忽略的目录”)后,LSP 引擎要把这些目录告诉语言服务器,否则服务器照样索引它们。原来的
lsp-engine/src/scan_settings.rs按 provider 名字分支:rust→ 写进rust-analyzer.files.exclude,字面路径;go→ 写进gopls.directoryFilters,-<路径>形式,根目录写-,没有数组时先补默认的-**/node_modules,名字带通配符的目录跳过。这是 Core 认识具体语言服务器的写死逻辑,违反“Core 对语言和工具零特判”。其他语言的服务器拿不到这个能力,除非再往 Core 里加分支。
改动 / Changes
新声明
languageServers[].indexingExclusions(plugin-language-servers,新文件indexing_exclusions.rs)sectionentry${path}rootEntry?default?pathSyntax?literal(默认)或glob;glob时名字含* ? [ ] { }的目录不写入文本字段最多 256 字节、不含控制字符;违反时
plugin.manifest.invalid,字段languageServers[<n>].indexingExclusions.<field>。它挂在SessionDeclaration上(会话字段),所以不需要后端也能声明。传递路径不变
SessionDeclaration::policy()把声明放进启动计划的sessionPolicy。桌面端本来就把sessionPolicy当json.RawMessage原样交给lsp.startServer,所以桌面端不需要改代码,以后只升级PINNED_CORE_REVISION。plugin-server-policy:SessionPolicy接受indexingExclusions,并用同一套规则复核(lsp.startServer是公开命令)。lsp-engine:RuntimeSession保存声明;plugin_configuration()只按声明把排除目录追加进服务器读到的配置。scan_settings.rs删掉"rust" | "go"分支,只保留通用的“沿点分路径规整、追加、已存在的项移到末尾”逻辑。没有声明的服务器配置原样返回。default开始、根目录用rootEntry”的断言。indexing_cold_start_resolves_git_before_provider_initialization改成用一个虚构的io.example.server分别跑 glob 和字面路径两种声明,并断言没有声明时配置不变。契约
contract/v1/README.md:语言服务器字段表加一行;新增 “Indexing exclusions” 小节;sessionPolicy说明加上indexingExclusions。“Core 从不按语言 ID、服务器 ID 或工具名分支”这句话现在名副其实。plugin-manifest.schema.json:加indexingExclusions及$defs/indexingExclusionLiteral。language-system-command.plugin.json(gopls)加上与原写死逻辑等价的声明,command-plans.json的对应计划带上它;invalid-manifests.json加 4 个拒绝用例(entry没有${path}、section有空键、default带模板、pathSyntax不认识)。reference/domains/languages.md中英两节、capabilities-and-versions.md、protocol-changelog.md同步。发布顺序与过渡期 / Rollout
旧宿主的
LanguageServerDeclaration是deny_unknown_fields,不认识indexingExclusions,会拒绝带它的清单(已用同样的 serde 结构确认:unknown field indexingExclusions)。所以顺序是:main;PINNED_CORE_REVISION升到合入后的 commit 并发布;languageServers[0]加上与 fixture 相同的声明并发版(Draft:https://github.com/Lithe-IDEA/lithe-plugin-go/pull/17),同时把e2e/host/lithe-host.json的宿主固定版本升到第 2 步的 commit。第 2 步到第 3 步之间,装旧版 Go 插件(1.0.1)的用户,gopls 拿不到排除目录,会照常索引被排除的目录。这只影响 gopls 的索引范围和资源占用:宿主照常不向它发送被排除目录里的文档、诊断和文件变化。仓库里没有 Rust 语言服务器插件,rust-analyzer 这条没有需要补的声明。
不在本 PR 范围内 / Out of scope
类型专属:fix
复现与根因
rust、go。检查项
scan_settings单测和indexing_cold_start_resolves_git_before_provider_initialization覆盖两种声明和“未声明不改配置”;新增indexing_exclusions的 3 个单测覆盖填充顺序、glob 过滤、全部校验边界。-**/node_modules、-、-vendor、带通配符的目录跳过),由单测断言。scan_settings、provider分支的全部调用方:只有RuntimeSession::plugin_configuration()。范围检查 / Scope checks
插件契约 / Plugin contract
shared/plugins/contract/v1/:README、schema、fixture 都在本 PR;协议更新记录已登记(languageServers0 内的补充,API-25)。逻辑归属 / Logic placement
无用代码与重构 / Dead code and refactoring
scan_settings里按 provider 分支的代码和只服务于它的辅助逻辑已删除。其他组(功能矩阵、UI、日志、i18n、性能、设置、发行包):N/A,Core 这边没有涉及。
验证 / Verification
cargo fmt --checkcargo test -p lithe-plugin-language-servers -p lithe-plugin-server-policy -p lithe-plugin-manifest -p lithe-lsp-enginecargo test -p lithe-corecargo clippy --workspace --all-targets --features lithe-remote/server -- -D warningsbash scripts/rust-core/verify-rust-core-comments.shnode scripts/rust-core/verify-platform-tests.mjsnode shared/plugins/scripts/verify-docs.mjsnode scripts/rust-core/affected-crates.mjs --base origin/main--workspace;macOS、Windows:lithe-platform 一组main(cad565600):LITHE_CORE_RUST_DIR=<本分支> scripts/desktop/desktop-go.sh test -count=1 ./internal/core./internal/pluginbackend ./internal/marketplace ./internal/pluginservice ./internal/workbench(在 1lck/Lithe-IDEA#2036 的分支上跑,这几个包与该分支的改动无关)LITHE_CORE_RUST_DIR=<本分支> node scripts/e2e-host.mjs --ref cad5656005288a7ef5897abd9d15494d2faf2fde,插件包带indexingExclusions未能执行的检查和原因: 完整
cargo test --workspace由 Draft 的 Linux CI 运行。Windows 没有在本机执行,由 ready 后的 CI 覆盖。上面的 e2e 临时模块里没有被排除的目录,directoryFilters的内容由本 PR 的单元测试断言。提交前确认 / Final checks
main(957a349)创建,目标分支main