diff options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/code/package.json | 27 | ||||
-rw-r--r-- | editors/code/src/commands.ts | 21 | ||||
-rw-r--r-- | editors/code/src/lsp_ext.ts | 6 | ||||
-rw-r--r-- | editors/code/src/main.ts | 1 |
4 files changed, 50 insertions, 5 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index eccafccdd..220d44abc 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -187,6 +187,11 @@ | |||
187 | "command": "rust-analyzer.openDocs", | 187 | "command": "rust-analyzer.openDocs", |
188 | "title": "Open docs under cursor", | 188 | "title": "Open docs under cursor", |
189 | "category": "Rust Analyzer" | 189 | "category": "Rust Analyzer" |
190 | }, | ||
191 | { | ||
192 | "command": "rust-analyzer.openCargoToml", | ||
193 | "title": "Open Cargo.toml", | ||
194 | "category": "Rust Analyzer" | ||
190 | } | 195 | } |
191 | ], | 196 | ], |
192 | "keybindings": [ | 197 | "keybindings": [ |
@@ -278,6 +283,11 @@ | |||
278 | "default": null, | 283 | "default": null, |
279 | "description": "Specify the compilation target" | 284 | "description": "Specify the compilation target" |
280 | }, | 285 | }, |
286 | "rust-analyzer.noSysroot": { | ||
287 | "markdownDescription": "Internal config for debugging, disables loading of sysroot crates", | ||
288 | "type": "boolean", | ||
289 | "default": false | ||
290 | }, | ||
281 | "rust-analyzer.rustfmt.extraArgs": { | 291 | "rust-analyzer.rustfmt.extraArgs": { |
282 | "type": "array", | 292 | "type": "array", |
283 | "items": { | 293 | "items": { |
@@ -600,11 +610,6 @@ | |||
600 | }, | 610 | }, |
601 | "default": null | 611 | "default": null |
602 | }, | 612 | }, |
603 | "rust-analyzer.withSysroot": { | ||
604 | "markdownDescription": "Internal config for debugging, disables loading of sysroot crates", | ||
605 | "type": "boolean", | ||
606 | "default": true | ||
607 | }, | ||
608 | "rust-analyzer.diagnostics.enable": { | 613 | "rust-analyzer.diagnostics.enable": { |
609 | "type": "boolean", | 614 | "type": "boolean", |
610 | "default": true, | 615 | "default": true, |
@@ -687,6 +692,14 @@ | |||
687 | }, | 692 | }, |
688 | "default": [], | 693 | "default": [], |
689 | "description": "Additional arguments to be passed to cargo for runnables such as tests or binaries.\nFor example, it may be '--release'" | 694 | "description": "Additional arguments to be passed to cargo for runnables such as tests or binaries.\nFor example, it may be '--release'" |
695 | }, | ||
696 | "rust-analyzer.rustcSource": { | ||
697 | "type": [ | ||
698 | "null", | ||
699 | "string" | ||
700 | ], | ||
701 | "default": null, | ||
702 | "description": "Path to the rust compiler sources, for usage in rustc_private projects." | ||
690 | } | 703 | } |
691 | } | 704 | } |
692 | }, | 705 | }, |
@@ -1057,6 +1070,10 @@ | |||
1057 | { | 1070 | { |
1058 | "command": "rust-analyzer.openDocs", | 1071 | "command": "rust-analyzer.openDocs", |
1059 | "when": "inRustProject" | 1072 | "when": "inRustProject" |
1073 | }, | ||
1074 | { | ||
1075 | "command": "rust-analyzer.openCargoToml", | ||
1076 | "when": "inRustProject" | ||
1060 | } | 1077 | } |
1061 | ] | 1078 | ] |
1062 | } | 1079 | } |
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index cf34622c3..92bc4d7f7 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts | |||
@@ -188,6 +188,27 @@ export function parentModule(ctx: Ctx): Cmd { | |||
188 | }; | 188 | }; |
189 | } | 189 | } |
190 | 190 | ||
191 | export function openCargoToml(ctx: Ctx): Cmd { | ||
192 | return async () => { | ||
193 | const editor = ctx.activeRustEditor; | ||
194 | const client = ctx.client; | ||
195 | if (!editor || !client) return; | ||
196 | |||
197 | const response = await client.sendRequest(ra.openCargoToml, { | ||
198 | textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), | ||
199 | }); | ||
200 | if (!response) return; | ||
201 | |||
202 | const uri = client.protocol2CodeConverter.asUri(response.uri); | ||
203 | const range = client.protocol2CodeConverter.asRange(response.range); | ||
204 | |||
205 | const doc = await vscode.workspace.openTextDocument(uri); | ||
206 | const e = await vscode.window.showTextDocument(doc); | ||
207 | e.selection = new vscode.Selection(range.start, range.start); | ||
208 | e.revealRange(range, vscode.TextEditorRevealType.InCenter); | ||
209 | }; | ||
210 | } | ||
211 | |||
191 | export function ssr(ctx: Ctx): Cmd { | 212 | export function ssr(ctx: Ctx): Cmd { |
192 | return async () => { | 213 | return async () => { |
193 | const editor = vscode.window.activeTextEditor; | 214 | const editor = vscode.window.activeTextEditor; |
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index d320c3cd7..5e877ce65 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts | |||
@@ -114,3 +114,9 @@ export interface CommandLinkGroup { | |||
114 | } | 114 | } |
115 | 115 | ||
116 | export const openDocs = new lc.RequestType<lc.TextDocumentPositionParams, string | void, void>('experimental/externalDocs'); | 116 | export const openDocs = new lc.RequestType<lc.TextDocumentPositionParams, string | void, void>('experimental/externalDocs'); |
117 | |||
118 | export const openCargoToml = new lc.RequestType<OpenCargoTomlParams, lc.Location, void>("experimental/openCargoToml"); | ||
119 | |||
120 | export interface OpenCargoTomlParams { | ||
121 | textDocument: lc.TextDocumentIdentifier; | ||
122 | } | ||
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 09543e348..2f3dde8ac 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -111,6 +111,7 @@ async function tryActivate(context: vscode.ExtensionContext) { | |||
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 | ctx.registerCommand('openDocs', commands.openDocs); |
114 | ctx.registerCommand('openCargoToml', commands.openCargoToml); | ||
114 | 115 | ||
115 | defaultOnEnter.dispose(); | 116 | defaultOnEnter.dispose(); |
116 | ctx.registerCommand('onEnter', commands.onEnter); | 117 | ctx.registerCommand('onEnter', commands.onEnter); |