Skip to content

[Feature] Core 剩余的语言专属默认值(忽略目录、索引排除、go/node 运行时、运行发现、行注释表)改由插件注入 #1856

Closed

Description

@xiaoyumuxi

Problem to solve / 要解决的问题

规则是 Core 不依赖 Java 等任何语言,也不为它们写特殊处理,语言和工具专属的知识全部由插件注入。Core 的 Java/Maven/JDT 特判已在 Lithe-IDEA/Lithe-core-rust 分支 refactor/core-remove-java-special-cases 删除,但生产代码里还剩 5 类按语言或工具写死的默认值。插件现在没有入口声明或覆盖它们:

  • 没装对应插件,这些默认值照样生效;
  • 装了插件也改不了;
  • 新增一门语言只能改 Core。

下面的行号以该分支为准。

1. 默认忽略目录名单:3 份,内容互不相同

位置 用途
rust/lithe-core/src/execution/workspace_scan.rs:16 EXCLUDED_DIRECTORIES(34 项) 运行发现、运行配置指纹、宿主文件列表
rust/lithe-core/src/vcs/roots.rs:29 PRUNED(25 项) VCS 根目录扫描
rust/lithe-core/src/project/history.rs:34 BUILT_IN_IGNORED_DIRECTORY_NAMES(30 项) 本地历史

这 3 份名单写死了各生态的目录,例如:

  • .gradle、target、build、out、obj
  • node_modules、bower_components、.next、.nuxt、.svelte-kit
  • .venv、venv、__pycache__、.tox、.mypy_cache、.pytest_cache、.ruff_cache、.uv-cache
  • Pods、DerivedData、.swiftpm、.build
  • .dart_tool、.stack-work、.cargo、.terraform、.bundle、vendor

2. rust-analyzer / gopls 的索引排除覆盖

  • 位置:rust/lithe-core/src/lsp/languages/indexing.rs configuration、with_roots。调用点是 rust/lithe-core/src/lsp/interface/engine.rs:1052。
  • 行为:provider 为 "rust" 或 "go" 时,Core 把工作区排除目录写进 rust-analyzer.files.exclude 或 gopls 的 directoryFilters。它按名字识别这两个语言服务器,还写死了它们的配置键和格式。

3. 宿主自管的运行时 go、node

  • 位置:rust/lithe-core/src/plugins/declarative.rs:93 KNOWN_RUNTIME_TOOLS = ["go", "node"],由 rust/lithe-core/src/build/manifest.rs:241 RuntimeDependency::is_host_managed 使用。
  • 行为:构建系统的运行时依赖如果是这两个 ID,就由宿主自己发现,导出 LITHE_GO_PATH、LITHE_NODE_PATH,并加入 PATH。其他 ID 必须是工具定义。

4. 运行配置自动发现

  • 位置:
    • rust/lithe-core/src/execution/detectors/{cargo,compose,go,make,npm,procfile,python,shell}.rs;
    • rust/lithe-core/src/execution/configuration.rs:2277 的 fingerprint_input,其中写死了清单文件名:package.json、各类锁文件、Cargo.toml、rust-toolchain*、go.mod、pyproject.toml、manage.py、Procfile*、Makefile、docker-compose.*、compose.*、mise.toml。
  • 行为:Core 内置各工具的探测规则和命令模板。

5. 行注释符号表

  • 位置:rust/lithe-core/src/editor/line_edit.rs:137 lookup_line_comment_token,供 editor.lineCommentToken 使用。
  • 行为:按扩展名或语言 ID 写死 //、#、--。插件已经可以通过 languages:2 的编辑配置声明 lineComment(校验在 rust/lithe-core/src/plugins/grammar.rs:105),所以现在插件声明和 Core 内置表两套并存。

保留的代价

  • 违反 Core 零语言特判的规则。新语言或新工具要改 Core 才能获得忽略目录、运行发现和行注释。

  • Core 内置名单与插件声明会给出不同答案。例如插件声明了 lineComment,但 editor.lineCommentToken 查的是 Core 的表。

  • 忽略名单有 3 份,内容不一致:

    • 三份共有 17 项。
    • vendor、obj、.bundle 只在运行扫描名单里。
    • .ruff_cache、.uv-cache、.cache、.artifacts、.svn,以及本仓库专用的 design-qa-artifacts、.claude,只在本地历史名单里。

    结果是用户在不同功能里看到的“哪些目录被忽略”不一样。

Proposed solution / 建议方案

Core 只保留与语言无关的机制和中立的默认值,例如 VCS 元数据目录和 Lithe 自己的目录;语言和工具的部分由插件声明,Core 负责合并、校验和执行。每项对应 API 实施计划的编号如下:

项 改为 计划编号
1. 默认忽略目录 插件在语言或构建系统贡献里声明生成目录和依赖目录。Core 合并“中立默认值 + 已安装插件的声明 + 用户设置”,得到一份名单,供运行扫描、VCS 根扫描、本地历史和搜索共用,替代现在的 3 份 API-06(工作区读取的隐藏/忽略规则)、API-08(搜索的忽略规则)
2. 索引排除覆盖 语言服务器贡献声明“把工作区排除目录写进哪个配置键、用什么格式”,或者由插件后端在配置请求里自己合并。Core 不再按 rust/go 识别语言服务器 API-25
3. go、node 运行时 删除 KNOWN_RUNTIME_TOOLS。Go、Node 由对应插件提供工具定义,运行时依赖一律引用工具定义 ID API-23
4. 运行配置自动发现 各探测器迁到对应插件(Cargo、Go、Node、Python、Docker 等),作为运行准备或任务 Provider 提供;指纹输入改由 Provider 声明。Make、Procfile、Shell 这类不属于任何语言的探测,也按“工具专属知识归插件”处理 API-29
5. 行注释符号表 删除 lookup_line_comment_token。editor.lineCommentToken 只从已安装插件 languages:2 编辑配置的 lineComment 解析,没有声明时返回 null API-25(languages:2 编辑配置)

风险:

  • 迁移期间,没装对应插件的工作区会失去这些默认行为,例如不再忽略 node_modules、不再发现 npm 脚本。各项应该先在插件里补上声明,Core 再删除内置表,分项发布。
  • 第 1、4 项会改变插件清单契约,需要在 Core 的 shared/plugins/ 同一个 PR 里更新契约、能力版本和协议更新记录。

Target platform / 目标平台

Cross-platform / 跨平台

Area / 模块

Extensions / 扩展

Priority / 优先级

P2 / 后续考虑:目前不着急,可安排到后续版本

Alternatives considered / 已考虑的替代方案

  • 把这些名单挪到 Core 的 JSON 资源文件。不采用:知识仍归 Core 所有,插件依然改不了,只是换了个地方写死。
  • 只删除 Java 相关条目(如 .gradle)。不采用:其他语言的条目有同样的问题,规则也不按语言区分。

Additional context / 补充信息

Checklist / 提交前检查

  • I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复建议。

Activity

  1. added
    review: high
    on Nov 13, 2026
  2. added
    enhancement
    P2
    area:extensions
    on Nov 13, 2026
  3. xiaoyumuxi commented on Nov 13, 2026

    @xiaoyumuxi
    CollaboratorAuthor

    Lithe-IDEA/Lithe-core-rust#28 把 lithe-core 拆成了独立 crate,正文里的旧路径已经失效。下表是新位置,行号以 #28 的分支 refactor/core-split-logging-workspace 为准。#28 只搬代码、不改行为,这 5 类默认值都还在,本 Issue 继续有效。

    项 旧位置 新位置
    1. 忽略目录:运行扫描 rust/lithe-core/src/execution/workspace_scan.rs:16 rust/crates/execution/src/workspace_scan.rs:16 EXCLUDED_DIRECTORIES
    1. 忽略目录:VCS 根扫描 rust/lithe-core/src/vcs/roots.rs:29 rust/crates/vcs/src/roots.rs:29 PRUNED
    1. 忽略目录:本地历史 rust/lithe-core/src/project/history.rs:34 rust/crates/project/src/history.rs:34 BUILT_IN_IGNORED_DIRECTORY_NAMES
    2. rust-analyzer / gopls 覆盖 rust/lithe-core/src/lsp/languages/indexing.rs rust/crates/lsp-engine/src/scan_settings.rs configuration、with_roots;调用点 rust/crates/lsp-engine/src/configuration.rs:157
    3. go、node 运行时 rust/lithe-core/src/plugins/declarative.rs:93、rust/lithe-core/src/build/manifest.rs:241 rust/crates/build/src/manifest/invocation.rs:28 KNOWN_RUNTIME_TOOLS、:54 is_host_managed
    4. 运行发现探测器 rust/lithe-core/src/execution/detectors/ rust/crates/execution/src/detectors/{cargo,compose,go,make,npm,procfile,python,shell}.rs
    4. 指纹输入 rust/lithe-core/src/execution/configuration.rs:2277 rust/crates/execution/src/configuration/inputs.rs:118 fingerprint_input
    5. 行注释表 rust/lithe-core/src/editor/line_edit.rs:137 rust/crates/editor/src/line_edit.rs:148 lookup_line_comment_token
    5. 插件 lineComment 校验 rust/lithe-core/src/plugins/grammar.rs:105 rust/crates/plugin-grammar/src/lib.rs:110

    #28 合入后,这些路径在 main 上同样适用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2area:extensionsenhancementplatform:cross-platformreview: high

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions