From da7ec4b3398ffaf672a755bf57066e17ac42303a Mon Sep 17 00:00:00 2001 From: vsrs Date: Wed, 3 Jun 2020 14:34:11 +0300 Subject: Add hover actions LSP extension documentation. --- docs/dev/lsp-extensions.md | 38 ++++++++++++++++++++++++++++++++++++++ editors/code/src/client.ts | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 7f7940d0b..a0847dad3 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -467,3 +467,41 @@ interface InlayHint { 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 + +-----------------------------+ + ... +``` \ No newline at end of file diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 9df670283..f2094b5ce 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -66,7 +66,7 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient // Workaround to support command links (trusted vscode.MarkdownString) in hovers // https://github.com/microsoft/vscode/issues/33577 hover.contents = hover.contents.map(toTrusted); - + const actions = (result).actions; if (actions) { hover.contents.push(renderHoverActions(actions)); -- cgit v1.2.3