diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/package.json | 23 | ||||
-rw-r--r-- | editors/code/src/commands.ts | 15 | ||||
-rw-r--r-- | editors/code/src/lsp_ext.ts | 3 |
3 files changed, 33 insertions, 8 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index 448e2269f..1adf055d0 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -200,11 +200,6 @@ | |||
200 | "type": "object", | 200 | "type": "object", |
201 | "title": "Rust Analyzer", | 201 | "title": "Rust Analyzer", |
202 | "properties": { | 202 | "properties": { |
203 | "rust-analyzer.diagnostics.enable": { | ||
204 | "type": "boolean", | ||
205 | "default": true, | ||
206 | "markdownDescription": "Whether to show native rust-analyzer diagnostics." | ||
207 | }, | ||
208 | "rust-analyzer.lruCapacity": { | 203 | "rust-analyzer.lruCapacity": { |
209 | "type": [ | 204 | "type": [ |
210 | "null", | 205 | "null", |
@@ -328,6 +323,14 @@ | |||
328 | "default": true, | 323 | "default": true, |
329 | "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)" | 324 | "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)" |
330 | }, | 325 | }, |
326 | "rust-analyzer.checkOnSave.noDefaultFeatures": { | ||
327 | "type": [ | ||
328 | "null", | ||
329 | "boolean" | ||
330 | ], | ||
331 | "default": null, | ||
332 | "markdownDescription": "Do not activate the `default` feature" | ||
333 | }, | ||
331 | "rust-analyzer.checkOnSave.allFeatures": { | 334 | "rust-analyzer.checkOnSave.allFeatures": { |
332 | "type": [ | 335 | "type": [ |
333 | "null", | 336 | "null", |
@@ -579,6 +582,16 @@ | |||
579 | "type": "boolean", | 582 | "type": "boolean", |
580 | "default": true | 583 | "default": true |
581 | }, | 584 | }, |
585 | "rust-analyzer.diagnostics.enable": { | ||
586 | "type": "boolean", | ||
587 | "default": true, | ||
588 | "markdownDescription": "Whether to show native rust-analyzer diagnostics." | ||
589 | }, | ||
590 | "rust-analyzer.diagnostics.enableExperimental": { | ||
591 | "type": "boolean", | ||
592 | "default": true, | ||
593 | "markdownDescription": "Whether to show experimental rust-analyzer diagnostics that might have more false positives than usual." | ||
594 | }, | ||
582 | "rust-analyzer.diagnostics.warningsAsInfo": { | 595 | "rust-analyzer.diagnostics.warningsAsInfo": { |
583 | "type": "array", | 596 | "type": "array", |
584 | "uniqueItems": true, | 597 | "uniqueItems": true, |
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 1f3a7cf7e..d0faf4745 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts | |||
@@ -185,15 +185,22 @@ export function parentModule(ctx: Ctx): Cmd { | |||
185 | 185 | ||
186 | export function ssr(ctx: Ctx): Cmd { | 186 | export function ssr(ctx: Ctx): Cmd { |
187 | return async () => { | 187 | return async () => { |
188 | const editor = vscode.window.activeTextEditor; | ||
188 | const client = ctx.client; | 189 | const client = ctx.client; |
189 | if (!client) return; | 190 | if (!editor || !client) return; |
191 | |||
192 | const position = editor.selection.active; | ||
193 | const selections = editor.selections; | ||
194 | const textDocument = { uri: editor.document.uri.toString() }; | ||
190 | 195 | ||
191 | const options: vscode.InputBoxOptions = { | 196 | const options: vscode.InputBoxOptions = { |
192 | value: "() ==>> ()", | 197 | value: "() ==>> ()", |
193 | prompt: "Enter request, for example 'Foo($a) ==> Foo::new($a)' ", | 198 | prompt: "Enter request, for example 'Foo($a) ==> Foo::new($a)' ", |
194 | validateInput: async (x: string) => { | 199 | validateInput: async (x: string) => { |
195 | try { | 200 | try { |
196 | await client.sendRequest(ra.ssr, { query: x, parseOnly: true }); | 201 | await client.sendRequest(ra.ssr, { |
202 | query: x, parseOnly: true, textDocument, position, selections, | ||
203 | }); | ||
197 | } catch (e) { | 204 | } catch (e) { |
198 | return e.toString(); | 205 | return e.toString(); |
199 | } | 206 | } |
@@ -208,7 +215,9 @@ export function ssr(ctx: Ctx): Cmd { | |||
208 | title: "Structured search replace in progress...", | 215 | title: "Structured search replace in progress...", |
209 | cancellable: false, | 216 | cancellable: false, |
210 | }, async (_progress, _token) => { | 217 | }, async (_progress, _token) => { |
211 | const edit = await client.sendRequest(ra.ssr, { query: request, parseOnly: false }); | 218 | const edit = await client.sendRequest(ra.ssr, { |
219 | query: request, parseOnly: false, textDocument, position, selections, | ||
220 | }); | ||
212 | 221 | ||
213 | await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit)); | 222 | await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit)); |
214 | }); | 223 | }); |
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index 5f32cb40e..494d51c83 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts | |||
@@ -93,6 +93,9 @@ export const inlayHints = new lc.RequestType<InlayHintsParams, InlayHint[], void | |||
93 | export interface SsrParams { | 93 | export interface SsrParams { |
94 | query: string; | 94 | query: string; |
95 | parseOnly: boolean; | 95 | parseOnly: boolean; |
96 | textDocument: lc.TextDocumentIdentifier; | ||
97 | position: lc.Position; | ||
98 | selections: lc.Range[]; | ||
96 | } | 99 | } |
97 | export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr'); | 100 | export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr'); |
98 | 101 | ||