Skip to content

Commit 332a33e

Browse files
authored
docs(plugins): 写明后端决定启动方式的语言服务器在立即生效的设置变化时重新调用启动函数取配置 (#176)
* docs(plugins): 写明后端决定启动方式的语言服务器在立即生效的设置变化时重新调用启动函数取配置 * docs(plugins): 更新记录填上 PR 编号 #176
1 parent dcb3d77 commit 332a33e

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

‎shared/plugins/contract/v1/README.md‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,11 @@ Core expands it with the merged settings
406406
requests by section path from it, and sends
407407
`workspace/didChangeConfiguration` after `initialized`. Hosts send a new
408408
value with `lsp.updateWorkspaceConfiguration` when an `immediate` setting
409-
changes; the running server receives it without a restart.
409+
changes; the running server receives it without a restart. The value
410+
replaces the whole configuration. For a server whose
411+
[backend-resolved launch](#backend-resolved-launch) answer carried its own
412+
`workspaceConfiguration`, the new value comes from the launch function
413+
again, not from the declaration.
410414

411415
#### Indexing exclusions
412416

@@ -1282,6 +1286,16 @@ declaring one:
12821286
starts it like any other. A server that is not launched by the backend is
12831287
`plugin.launch.notBackend`, so a host never runs an answer it did not ask
12841288
for.
1289+
- When an `immediate` setting changes while the server runs and its answer
1290+
carried `workspaceConfiguration`, the host calls `function` again with the
1291+
running start's directories, the workspace `context` and the new
1292+
`settings`, decodes the answer the same way, and sends only the plan's
1293+
`workspaceConfiguration` with `lsp.updateWorkspaceConfiguration`. The rest
1294+
of the answer waits for the next start. A function whose answer carries
1295+
`workspaceConfiguration` is therefore called more than once per start; one
1296+
that installs or downloads does so only when something is missing. When the
1297+
answer has no `workspaceConfiguration`, the host sends the declaration's
1298+
expansion and does not call the function again.
12851299

12861300
`resolveParams`:
12871301

‎shared/plugins/reference/domains/languages.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
#### 工作区配置(`workspaceConfiguration`)
9191

92-
语言服务器可以声明 `workspaceConfiguration`:一个对象,其中的字符串叶子可以是 `${setting:<id>}`。Core 用合并后的设置展开它,按节路径回答服务器的 `workspace/configuration` 请求,并在 `initialized` 之后发送 `workspace/didChangeConfiguration`。`immediate` 设置变化时,宿主通过 `lsp.updateWorkspaceConfiguration` 推送新值,运行中的服务器无需重启即可收到。
92+
语言服务器可以声明 `workspaceConfiguration`:一个对象,其中的字符串叶子可以是 `${setting:<id>}`。Core 用合并后的设置展开它,按节路径回答服务器的 `workspace/configuration` 请求,并在 `initialized` 之后发送 `workspace/didChangeConfiguration`。`immediate` 设置变化时,宿主通过 `lsp.updateWorkspaceConfiguration` 推送新值,运行中的服务器无需重启即可收到。新值整体替换原来的配置;[由后端决定启动方式](#后端决定启动方式launchkind-backend)、且应答自带 `workspaceConfiguration` 的服务器,新值由启动函数重新给出,不用声明的展开。
9393

9494
#### 索引排除(`indexingExclusions`)
9595

@@ -126,6 +126,7 @@
126126
| 调用 | 宿主建好四个目录,必要时启动插件后端,用 `lithe/function/invoke` 调用 `function`,参数是 `resolveParams`(`serverID`、`platform`、四个目录、`settings`)和工作区 `context`。调用失败、超时,或工作区代次已变,这次启动就不产生进程 |
127127
| 应答 | `executable`(`{kind: "packaged", path}` 是包内只读文件;`{kind: "tool", tool}` 是插件自己定义的工具,由宿主按工具解析)、`arguments`、`environment`、`initializationOptions`、`workspaceConfiguration`、`gates`(最多 8 个)、`writablePaths`(最多 32 个,都在四个目录之内);不认识的字段会被拒绝 |
128128
| 解码 | 宿主把 `{manifest, languageID, request, result}` 交给 `plugins.languageServers.decodeLaunch`,得到普通的启动计划(`launch` 为 `packaged` 或 `tool`),`sessionPolicy` 另带应答的 `gates` |
129+
| 设置立即生效 | 服务器运行中 `immediate` 设置变化、且应答自带 `workspaceConfiguration` 时,宿主用这次启动的四个目录、工作区 `context` 和新的 `settings` 再调用一次 `function`,同样解码,只把计划里的 `workspaceConfiguration` 通过 `lsp.updateWorkspaceConfiguration` 发出;应答的其余部分等下次启动才生效。所以这类函数每次启动可能被调用多次,安装或下载只应在缺少时进行。应答不带 `workspaceConfiguration` 时,宿主发送声明的展开,不再调用函数 |
129130
| 拒绝码 | `plugin.launch.invalidResult`、`plugin.launch.outsidePackage`、`plugin.launch.undeclaredTool`、`plugin.launch.unwritablePath`、`plugin.launch.invalidRequest`、`plugin.launch.unavailable`、`plugin.launch.notBackend`、`plugin.launch.untrustedWorkspace`(工作区未信任;用户在两步之间撤销信任时,第二步同样拒绝) |
130131

131132
### 插件自有会话(`languageServers` 的会话字段)
@@ -372,7 +373,7 @@ A plugin that declares a language owns its process-backed features: the host sto
372373

373374
#### Workspace configuration
374375

375-
A language server may declare `workspaceConfiguration`, an object whose string leaves may be `${setting:<id>}` templates. Core expands it with the merged settings, answers the server's `workspace/configuration` requests by section path, and sends `workspace/didChangeConfiguration` after `initialized`. When an `immediate` setting changes, the host sends the new value with `lsp.updateWorkspaceConfiguration`, and the running server receives it without a restart.
376+
A language server may declare `workspaceConfiguration`, an object whose string leaves may be `${setting:<id>}` templates. Core expands it with the merged settings, answers the server's `workspace/configuration` requests by section path, and sends `workspace/didChangeConfiguration` after `initialized`. When an `immediate` setting changes, the host sends the new value with `lsp.updateWorkspaceConfiguration`, and the running server receives it without a restart. The value replaces the whole configuration. For a [backend-resolved launch](#backend-resolved-launch-launchkind-backend) whose answer carried its own `workspaceConfiguration`, the launch function gives the new value again, not the declaration.
376377

377378
#### Indexing exclusions (`indexingExclusions`)
378379

@@ -409,6 +410,7 @@ When a server's command line depends on what is known only at start (a version i
409410
| Call | The host creates the four directories, starts the plugin backend if needed, and calls `function` through `lithe/function/invoke` with `resolveParams` (`serverID`, `platform`, the four directories, `settings`) and the workspace `context`. A failed or timed-out call, or a changed workspace generation, ends the start without a process |
410411
| Answer | `executable` (`{kind: "packaged", path}` is a read-only file in the package; `{kind: "tool", tool}` names a tool definition of the plugin, which the host resolves), `arguments`, `environment`, `initializationOptions`, `workspaceConfiguration`, `gates` (at most 8), and `writablePaths` (at most 32, all inside the four directories). An unknown field is refused |
411412
| Decoding | The host passes `{manifest, languageID, request, result}` to `plugins.languageServers.decodeLaunch`, which returns an ordinary launch plan (`launch` is `packaged` or `tool`); its `sessionPolicy` also carries the answer's `gates` |
413+
| Immediate settings | When an `immediate` setting changes while the server runs and its answer carried `workspaceConfiguration`, the host calls `function` again with the running start's four directories, the workspace `context` and the new `settings`, decodes the answer the same way, and sends only the plan's `workspaceConfiguration` with `lsp.updateWorkspaceConfiguration`; the rest of the answer waits for the next start. Such a function may therefore be called more than once per start, and should install or download only what is missing. When the answer has no `workspaceConfiguration`, the host sends the declaration's expansion and does not call the function again |
412414
| Rejections | `plugin.launch.invalidResult`, `plugin.launch.outsidePackage`, `plugin.launch.undeclaredTool`, `plugin.launch.unwritablePath`, `plugin.launch.invalidRequest`, `plugin.launch.unavailable`, `plugin.launch.notBackend`, `plugin.launch.untrustedWorkspace` (the workspace is not trusted; the second step refuses too when the user revoked trust between the steps) |
413415

414416
### Plugin-owned sessions

‎shared/plugins/reference/domains/settings.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
由 Core 在校验时检查的放置和使用规则:
7171

72-
- `immediate` 设置只能出现在语言服务器的 `workspaceConfiguration` 里,它从不进入命令行或 `initializationOptions`,所以修改它从不需要新进程。
72+
- `immediate` 设置只能出现在语言服务器的 `workspaceConfiguration` 里,它从不进入命令行或 `initializationOptions`,所以修改它从不需要新进程。[后端决定启动方式](languages.md#后端决定启动方式launchkind-backend)的服务器,启动函数也会收到 `immediate` 设置;设置变化时,只有函数重新给出的 `workspaceConfiguration` 立即生效。
7373
- `text`、`file`、`directory` 设置只能是一个完整的模板值,或某个 `name=` 参数的值,不能是较长参数的一部分。
7474

7575
### 设置区域
@@ -222,7 +222,7 @@ A setting may also say where it is shown and when a change takes effect. The hos
222222

223223
Placement and use rules that Core checks at validation:
224224

225-
- An `immediate` setting may appear only in a language server's `workspaceConfiguration`. It never reaches a command line or `initializationOptions`, so a change never needs a new process.
225+
- An `immediate` setting may appear only in a language server's `workspaceConfiguration`. It never reaches a command line or `initializationOptions`, so a change never needs a new process. A [backend-resolved launch](languages.md#backend-resolved-launch-launchkind-backend) function receives `immediate` settings too; when one changes, only the `workspaceConfiguration` the function gives again takes effect at once.
226226
- A `text`, `file`, or `directory` setting is a whole template value, or the value of one `name=` argument; it is never part of a longer argument.
227227

228228
### Settings regions

‎shared/plugins/reference/protocol-changelog.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
## 待合入
1616

17+
- [#176](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/176),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`languageServers` 0 内的说明补充(—):写明后端决定启动方式的语言服务器在 `immediate` 设置变化时的行为。启动应答自带 `workspaceConfiguration` 时,宿主用这次启动的四个目录、工作区 `context` 和新的 `settings` 再调用一次启动函数,同样交给 `plugins.languageServers.decodeLaunch` 解码,只把计划里的 `workspaceConfiguration` 通过 `lsp.updateWorkspaceConfiguration` 发出(整体替换原配置),应答的其余部分等下次启动;应答不带时发送声明的展开,不再调用函数。所以这类启动函数每次启动可能被调用多次,安装或下载只应在缺少时进行。契约 README 的 Workspace configuration 和 Backend-resolved launch 两节、`reference/domains/languages.md` 与 `settings.md` 的中英文随之补充。桌面端实现见 1lck/Lithe-IDEA#2319。Core 代码、能力版本、宿主方法、通知和协议字段都不变。
1718
- [#175](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/175),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`ui` 0 内的补充(API-13、API-23):撤回 #174 新增的 `ui` 1,设置区域 `tool` 行的可选布尔字段 `choose` 改为 `ui` 0 内的补充,清单写 `requires.ui: 0` 即可使用。`capabilities.rs` 和清单 schema 的 `requires.ui` 回到只有 0,能力对照表删去 `ui` 1 一行。`choose` 不是布尔值时 Core 以 `plugin.ui.invalidView` 拒绝整个结果,位置指向 `choose`;旧宿主的 Core 不认识这个字段,同样会拒绝带它的视图,所以插件要等包含本改动的桌面端发布后再写。fixture `ui/view-results.json` 改为两个用例(接受选择器、`choose` 不是布尔值时拒绝),替换原来“`requires.ui` 为 0 时拒绝”的用例。`ui` 1 没有随任何宿主发布过。没有新增能力版本、宿主方法、通知或进程协议字段。
1819
- [#174](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/174),[@xiaoyumuxi](https://github.com/xiaoyumuxi),**`ui` 1**(API-13、API-23):设置区域视图的 `tool` 行新增可选的布尔字段 `choose`,带上后这一行同时是该工具的选择器,像解释器下拉框一样列出自动选择、已发现和已添加的安装(带版本和来源)、添加目录和打开工具链页的入口;选择只改设置窗口的草稿,“应用”提交、“取消”丢弃,行上显示待提交的选择,应用后启动和运行拿到选中的安装。清单 `requires.ui` 为 0 时 Core 以 `plugin.ui.invalidView` 拒绝整个结果,位置指向 `choose`。契约 README 的插件视图一节补充:为某个工作区显示的视图(项目窗口里的工具窗口,或从项目窗口打开的设置页)调用时,带上该窗口的工作区上下文作为 invoke 的 `params.context`,后端可以在 `click` 里用它调用 `run/start` 等需要上下文的宿主方法;没有工作区时不带。fixture `ui/view-results.json` 新增一个用例,Node SDK 的视图节点类型加上 `choose`,Rust 和 Go SDK 的工作区上下文说明随之修正。没有新增宿主方法、通知或进程协议字段。(`ui` 1 已由 #175 撤回,`choose` 改为 `ui` 0 内的补充。)
1920
- [#173](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/173),[@xiaoyumuxi](https://github.com/xiaoyumuxi),市场索引 `schemaVersion` 0 内的补充(—):`plugins.marketplace.resolveSource` 的结果新增 `revision: { repository: { owner, name }, ref }`(托管在 GitHub 且不带查询参数的索引才有,否则为 null),输入新增可选的 `commit`,带上后结果多出 `pinned: { commit, indexURL, recommendationsURL }`,即同一批文件在该提交上的地址;`commit` 不是完整的 SHA-1 或 SHA-256 时返回新的拒绝码 `plugin.source.commitInvalid`。`indexURL` 仍是来源身份。宿主借此绕过 raw.githubusercontent.com 对分支地址约 5 分钟的缓存,查询或固定下载失败时退回原地址。fixture `marketplace/source-urls.json` 从 11 个用例增加到 17 个。索引格式、插件清单、宿主方法和能力版本都不变。

0 commit comments

Comments
 (0)