mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-27 04:15:08 +00:00
Add hover actions LSP extension documentation.
This commit is contained in:
parent
7d0dd17b09
commit
da7ec4b339
2 changed files with 39 additions and 1 deletions
|
@ -467,3 +467,41 @@ interface InlayHint {
|
||||||
label: string,
|
label: string,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Hover Actions
|
||||||
|
|
||||||
|
**Client Capability:** `{ "hoverActions": boolean }`
|
||||||
|
|
||||||
|
If this capability is set, `Hover` request returned from the server might contain an additional field, `actions`:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface Hover {
|
||||||
|
...
|
||||||
|
actions?: CommandLinkGroup[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CommandLink extends Command {
|
||||||
|
/**
|
||||||
|
* A tooltip for the command, when represented in the UI.
|
||||||
|
*/
|
||||||
|
tooltip?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CommandLinkGroup {
|
||||||
|
title?: string;
|
||||||
|
commands: CommandLink[];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Such actions on the client side are appended to a hover bottom as command links:
|
||||||
|
```
|
||||||
|
+-----------------------------+
|
||||||
|
| Hover content |
|
||||||
|
| |
|
||||||
|
+-----------------------------+
|
||||||
|
| _Action1_ | _Action2_ | <- first group, no TITLE
|
||||||
|
+-----------------------------+
|
||||||
|
| TITLE _Action1_ | _Action2_ | <- second group
|
||||||
|
+-----------------------------+
|
||||||
|
...
|
||||||
|
```
|
|
@ -66,7 +66,7 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient
|
||||||
// Workaround to support command links (trusted vscode.MarkdownString) in hovers
|
// Workaround to support command links (trusted vscode.MarkdownString) in hovers
|
||||||
// https://github.com/microsoft/vscode/issues/33577
|
// https://github.com/microsoft/vscode/issues/33577
|
||||||
hover.contents = hover.contents.map(toTrusted);
|
hover.contents = hover.contents.map(toTrusted);
|
||||||
|
|
||||||
const actions = (<any>result).actions;
|
const actions = (<any>result).actions;
|
||||||
if (actions) {
|
if (actions) {
|
||||||
hover.contents.push(renderHoverActions(actions));
|
hover.contents.push(renderHoverActions(actions));
|
||||||
|
|
Loading…
Reference in a new issue