Skip to content

feat: gopls 的索引排除改由清单声明 indexingExclusions - #17

Merged
xiaoyumuxi merged 1 commit into
mainfrom
refactor/1856-indexing-exclusions
Nov 17, 2026
Merged

xiaoyumuxi merged 1 commit into
mainfrom
refactor/1856-indexing-exclusions

Conversation

@xiaoyumuxi

Copy link
Copy Markdown
Contributor

关联 Issue / Linked issue

改动说明 / What changes

Lithe 原来在 Core 里按 provider 名字 go 写死 gopls 的索引排除:把用户排除在索引之外的目录写进 gopls.directoryFilters。Lithe-core-rust#68 删除了这段特判,改成语言服务器在清单里声明 indexingExclusions,Core 只按声明填充。本 PR 给 gopls 补上这份声明。

  • plugin.json:languageServers[0] 加
    "indexingExclusions": {
      "section": "gopls.directoryFilters",
      "entry": "-${path}",
      "rootEntry": "-",
      "default": ["-**/node_modules"],
      "pathSyntax": "glob"
    }
    效果与原来 Core 的写死逻辑一致:每个排除的目录写成 -<相对路径>,工作区根目录写成 -;配置里没有 directoryFilters 时从 gopls 的默认值 -**/node_modules 开始追加;目录名含 * ? [ ] { } 的不写入。用户自己设置的项保留在前面。
  • README.md:“工作方式”加一条说明;“兼容性”写明这个字段需要固定了包含 Lithe-core-rust#68 的 Core 的桌面端。
  • docs/feature-matrix.md:go-support-plugin 的能力和依赖的宿主能力补上 indexingExclusions。

为什么是 Draft,什么时候可以合入

旧桌面端的 LanguageServerDeclaration 拒绝不认识的字段(deny_unknown_fields),会拒绝带 indexingExclusions 的整份清单。所以顺序是:

  1. Lithe-core-rust#68 合入 Core main;
  2. 桌面端把 PINNED_CORE_REVISION 升到合入后的 commit 并发布;
  3. 本 PR:把 e2e/host/lithe-host.json 的 revision 升到第 2 步的桌面端 commit,跑一遍 node scripts/e2e-host.mjs,升版本号写发布说明,然后 ready、合入、发版。

第 2 步到第 3 步之间,gopls 拿不到排除目录,会照常索引被排除的目录;宿主仍然不向它发送这些目录里的文档、诊断和文件变化。

验证 / Verification

命令或操作 平台 结果
node scripts/package.mjs macOS arm64 通过
LITHE_CORE_RUST_DIR=<Lithe-core-rust#68 分支> LITHE_TEST_GO_PLUGIN_ARCHIVE=dist/go-support-1.0.1-darwin.zip node scripts/e2e-host.mjs --ref cad5656005288a7ef5897abd9d15494d2faf2fde(桌面端 main,固定的 Core 957a349 正是 #68 的基点) macOS arm64 通过:projectgen 5 个、workbench 2 个(含 TestOfficialGoPluginBuildsAndServesAModule:清单被接受,gopls 诊断和 gofumpt 设置照常生效)

这次 e2e 的临时模块里没有被排除的目录,所以它证明的是“宿主接受这份清单、gopls 照常工作”;directoryFilters 填出来的内容由 Lithe-core-rust#68 的单元测试按同一份声明断言。e2e/host/lithe-host.json 的固定版本没有改,因为还没有包含 #68 的桌面端 commit。Windows 没有在本机执行。

Lithe 原来在 Core 里按 provider 名字 go 写死 gopls.directoryFilters 的键和写法(Lithe-core-rust#68 删除)。现在由插件声明:排除的目录写成 -<相对路径>,工作区根目录写成 -,没有数组时从 gopls 默认值 -**/node_modules 开始,名字含 glob 通配符的目录不写入,与原来的行为一致。

README 的工作方式和兼容性说明、功能矩阵同步更新。旧桌面端不认识这个字段会拒绝整份清单,所以要等固定了包含 Lithe-core-rust#68 的 Core 的桌面端发布后再发版。

Refs 1lck/Lithe-IDEA#1856
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant