diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/package.json | 9 | ||||
-rw-r--r-- | editors/code/src/commands.ts | 25 | ||||
-rw-r--r-- | editors/code/src/lsp_ext.ts | 2 | ||||
-rw-r--r-- | editors/code/src/main.ts | 1 |
4 files changed, 35 insertions, 2 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index 6a712a8a8..4bd3117fc 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -182,6 +182,11 @@ | |||
182 | "command": "rust-analyzer.toggleInlayHints", | 182 | "command": "rust-analyzer.toggleInlayHints", |
183 | "title": "Toggle inlay hints", | 183 | "title": "Toggle inlay hints", |
184 | "category": "Rust Analyzer" | 184 | "category": "Rust Analyzer" |
185 | }, | ||
186 | { | ||
187 | "command": "rust-analyzer.openDocs", | ||
188 | "title": "Open docs under cursor", | ||
189 | "category": "Rust Analyzer" | ||
185 | } | 190 | } |
186 | ], | 191 | ], |
187 | "keybindings": [ | 192 | "keybindings": [ |
@@ -1044,6 +1049,10 @@ | |||
1044 | { | 1049 | { |
1045 | "command": "rust-analyzer.toggleInlayHints", | 1050 | "command": "rust-analyzer.toggleInlayHints", |
1046 | "when": "inRustProject" | 1051 | "when": "inRustProject" |
1052 | }, | ||
1053 | { | ||
1054 | "command": "rust-analyzer.openDocs", | ||
1055 | "when": "inRustProject" | ||
1047 | } | 1056 | } |
1048 | ] | 1057 | ] |
1049 | } | 1058 | } |
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 1a90f1b7d..1445e41d3 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts | |||
@@ -419,10 +419,31 @@ export function gotoLocation(ctx: Ctx): Cmd { | |||
419 | }; | 419 | }; |
420 | } | 420 | } |
421 | 421 | ||
422 | export function openDocs(ctx: Ctx): Cmd { | ||
423 | return async () => { | ||
424 | |||
425 | const client = ctx.client; | ||
426 | const editor = vscode.window.activeTextEditor; | ||
427 | if (!editor || !client) { | ||
428 | return; | ||
429 | }; | ||
430 | |||
431 | const position = editor.selection.active; | ||
432 | const textDocument = { uri: editor.document.uri.toString() }; | ||
433 | |||
434 | const doclink = await client.sendRequest(ra.openDocs, { position, textDocument }); | ||
435 | |||
436 | if (doclink != null) { | ||
437 | vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(doclink)); | ||
438 | } | ||
439 | }; | ||
440 | |||
441 | } | ||
442 | |||
422 | export function resolveCodeAction(ctx: Ctx): Cmd { | 443 | export function resolveCodeAction(ctx: Ctx): Cmd { |
423 | const client = ctx.client; | 444 | const client = ctx.client; |
424 | return async (params: ra.ResolveCodeActionParams) => { | 445 | return async () => { |
425 | const item: lc.WorkspaceEdit = await client.sendRequest(ra.resolveCodeAction, params); | 446 | const item: lc.WorkspaceEdit = await client.sendRequest(ra.resolveCodeAction, null); |
426 | if (!item) { | 447 | if (!item) { |
427 | return; | 448 | return; |
428 | } | 449 | } |
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index f286b68a6..fc8e120b3 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts | |||
@@ -118,3 +118,5 @@ export interface CommandLinkGroup { | |||
118 | title?: string; | 118 | title?: string; |
119 | commands: CommandLink[]; | 119 | commands: CommandLink[]; |
120 | } | 120 | } |
121 | |||
122 | export const openDocs = new lc.RequestType<lc.TextDocumentPositionParams, string | void, void>('experimental/externalDocs'); | ||
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 2896d90ac..09543e348 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -110,6 +110,7 @@ async function tryActivate(context: vscode.ExtensionContext) { | |||
110 | ctx.registerCommand('run', commands.run); | 110 | ctx.registerCommand('run', commands.run); |
111 | ctx.registerCommand('debug', commands.debug); | 111 | ctx.registerCommand('debug', commands.debug); |
112 | ctx.registerCommand('newDebugConfig', commands.newDebugConfig); | 112 | ctx.registerCommand('newDebugConfig', commands.newDebugConfig); |
113 | ctx.registerCommand('openDocs', commands.openDocs); | ||
113 | 114 | ||
114 | defaultOnEnter.dispose(); | 115 | defaultOnEnter.dispose(); |
115 | ctx.registerCommand('onEnter', commands.onEnter); | 116 | ctx.registerCommand('onEnter', commands.onEnter); |