feat(plugins): let plugins add to the hover of any language (#1931)

Plugin API 1.3 gains an optional hover-provider export (worlds plugin-hover
and hover): hover(doc, at) returns Markdown and the range it describes. A
plugin declares the hover kind under [[contributes.providers]] for any
language; the host asks it with the language server, under the edit-path
budget, and shows the server's hover first and each plugin's below a rule.
Declaring the kind needs engines.openidea ^1.3. The Rust SDK gains
openidea_plugin::hover and register_plugin!(T, hover); every shipped
component is rebuilt for the WIT change.
Цей коміт міститься в:
Pedro Pessoa authored and GitHub committed 2026-11-07 15:29:16 +08:00
1 джерело de4c325a28
коміт 50567473f7
55 files changed
+804 -25

No files matched your search

+22 -2
Переглянути файл
@@ -34,7 +34,7 @@ plugins/
├─ regex-tester/ # html view talking to its code, settings, the editor's selection
└─ license-header/ # file-opened events, quick fix, project scan in a task
sdk/rust/openidea-plugin/ # the Rust SDK (host API, Plugin trait, mock host)
crates/ide-plugin/tests/fixtures/ # test plugins: hello, jobs, language-toy, misbehave, semantic-tokens
crates/ide-plugin/tests/fixtures/ # test plugins: hello, jobs, language-toy, misbehave, semantic-tokens, hover
```
The plugin API is defined in [`wit/`](../wit/) (`openidea:[email protected]`, world
@@ -402,7 +402,7 @@ declaration matches the file's language are called (and loaded):
```toml
[[contributes.providers]]
kinds = ["definition", "line-markers", "completion"] # also "inline-completion", "code-actions", "semantic-tokens"
kinds = ["definition", "line-markers", "completion"] # also "inline-completion", "code-actions", "semantic-tokens", "hover"
languages = ["java", "xml"] # editor language ids; "*" for any
```
@@ -457,6 +457,26 @@ the language server's semantic tokens and win where they overlap one, so the
editor's colour scheme styles them like the server's. They are asked again
after each edit, under the edit-path budget; at most 65,536 per document.
#### Hover
The `hover` kind (API 1.3) adds Markdown to the hover of documents of the
declared languages, here too including languages the plugin doesn't
contribute. Register with `register_plugin!(MyPlugin, hover)` and implement
`openidea_plugin::hover::HoverProvider`:
```rust
impl HoverProvider for MyPlugin {
fn hover(&mut self, doc: &Document, at: Position) -> Option<Hover> {
Some(Hover::new("**orders.index** · `GET /orders`"))
}
}
```
The host asks the language server and the plugins together, under the
edit-path budget, and shows the server's hover first, then each plugin's
below a rule. `range`, when given, is the text the hover describes (used when
the server names none). At most 64 KiB of Markdown per plugin.
### Network and secrets
`host::fetch` makes an HTTPS request (plain HTTP only to `localhost`) to a host
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
eb76da4bc9db84dcbad34143bac18c9ecf974276f793009791a15aab2eee291d
9384d8964c7c05d3df06521e0d724a932fdd17608cbcede13ec2acadfab3783c
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
0a19948927a23de81b2a453b9992e021744093cbe41ea92daa9feb2b1bc9a2a9
9d7e857ef367eaa9748d1a2b05b7b45226c254aa578c29e1ed987c7353738acf
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
564bfd00694f27f35f09eb0b81d341207a755528b5fe7c46c96717b3868d0f65
3e11039d36306f51c728bf9d08030fe620de461fa5b0037700aea95c4d27714c
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
f3f447366fa38f9bf4911f35b6e899405b0e072ceee3ad5ea2fe90639d70fa53
ef50957a407c9aff9999fdd197a5e72c90b7ba77aedbd7569408262ab7e158be
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
85cad466adb94f2b58e62263617e885d1c47cf70db5e8b38942bd415f0d779af
7160b309f39fe973e67bb20d361384955aed6afe98f00db329c3026ffe923759
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
659446eda0b50aa0fb08f6af68f7d355fcaf3342847e2e579999dcf52a7a7399
1f1afa285a64a7f7758f08a80306d6397c8aee4d2ac7ed43369e77aae61add04
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
51ef9d43315ca9d7239999c222fbf7a2c01bc85c2b40f53f34a1a8e5d31baa6d
ddd9205da9fc947215ab90c505d8b443d0937b1dd11734e9ce94d277517c77a6
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
bdf9455c6e7c8c340c54d783f351220b38cffed36907e1b5a1f2e11801e6f5bb
c61a0ec6ffcbd71e590e5a16a6f08f2d2772481497edc77e11914cfb3d0bfcd1
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
7e4d00e1ea63b2eca48b9297667e04c05a9f9832f1dee2262272801d516b9a16
e11cd0b664ae058274808bc2b2152bac2738207979758d13bc0c0cd96c38ef4f
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
00cbd2dd7f0937554633ba5e533f19be85f70579c7c6fedb6fe0228f8f63bf4c
59319cf4be14448b0126b07d074cc08c351cfd12a3de26f111c2445fe8bff664
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
eecf2cf561dd5e3e3edbf9f67ccb479573dd538a75d4426a1d086edf0a310043
59844ae52aa765af404b43f7895db94d0063a3a6fce5bd54bf9af680ccac357b