aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/commands.ts25
-rw-r--r--editors/code/src/lsp_ext.ts11
-rw-r--r--editors/code/src/main.ts1
3 files changed, 35 insertions, 2 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 1a90f1b7d..b22cd450b 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
422export function openDocs(ctx: Ctx): Cmd {
423 return async () => {
424 console.log("running openDocs");
425
426 const client = ctx.client;
427 const editor = vscode.window.activeTextEditor;
428 if (!editor || !client) {
429 console.log("not yet ready");
430 return
431 };
432
433 const position = editor.selection.active;
434 const textDocument = { uri: editor.document.uri.toString() };
435
436 const doclink = await client.sendRequest(ra.openDocs, { position, textDocument });
437
438 vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(doclink.remote));
439 };
440
441}
442
422export function resolveCodeAction(ctx: Ctx): Cmd { 443export 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..569e747bd 100644
--- a/editors/code/src/lsp_ext.ts
+++ b/editors/code/src/lsp_ext.ts
@@ -118,3 +118,14 @@ export interface CommandLinkGroup {
118 title?: string; 118 title?: string;
119 commands: CommandLink[]; 119 commands: CommandLink[];
120} 120}
121
122export interface DocumentationLink {
123 remote: string;
124}
125
126export interface OpenDocsParams {
127 textDocument: lc.TextDocumentIdentifier;
128 position: lc.Position;
129}
130
131export const openDocs = new lc.RequestType<OpenDocsParams, DocumentationLink, void>('rust-analyzer/openDocs');
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);