diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/package-lock.json | 6 | ||||
-rw-r--r-- | editors/code/package.json | 22 | ||||
-rw-r--r-- | editors/code/src/client.ts | 9 | ||||
-rw-r--r-- | editors/code/src/commands/runnables.ts | 22 | ||||
-rw-r--r-- | editors/code/src/config.ts | 19 | ||||
-rw-r--r-- | editors/code/src/inlay_hints.ts | 2 | ||||
-rw-r--r-- | editors/code/src/main.ts | 1 | ||||
-rw-r--r-- | editors/code/src/rust-analyzer-api.ts | 3 |
8 files changed, 67 insertions, 17 deletions
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json index 77ee5a0cf..b07964546 100644 --- a/editors/code/package-lock.json +++ b/editors/code/package-lock.json | |||
@@ -114,9 +114,9 @@ | |||
114 | } | 114 | } |
115 | }, | 115 | }, |
116 | "@types/vscode": { | 116 | "@types/vscode": { |
117 | "version": "1.42.0", | 117 | "version": "1.43.0", |
118 | "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.42.0.tgz", | 118 | "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.43.0.tgz", |
119 | "integrity": "sha512-ds6TceMsh77Fs0Mq0Vap6Y72JbGWB8Bay4DrnJlf5d9ui2RSe1wis13oQm+XhguOeH1HUfLGzaDAoupTUtgabw==", | 119 | "integrity": "sha512-kIaR9qzd80rJOxePKpCB/mdy00mz8Apt2QA5Y6rdrKFn13QNFNeP3Hzmsf37Bwh/3cS7QjtAeGSK7wSqAU0sYQ==", |
120 | "dev": true | 120 | "dev": true |
121 | }, | 121 | }, |
122 | "@typescript-eslint/eslint-plugin": { | 122 | "@typescript-eslint/eslint-plugin": { |
diff --git a/editors/code/package.json b/editors/code/package.json index 7a4a93e30..3aaae357a 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -21,7 +21,7 @@ | |||
21 | "Programming Languages" | 21 | "Programming Languages" |
22 | ], | 22 | ], |
23 | "engines": { | 23 | "engines": { |
24 | "vscode": "^1.42.0" | 24 | "vscode": "^1.43.0" |
25 | }, | 25 | }, |
26 | "enableProposedApi": true, | 26 | "enableProposedApi": true, |
27 | "scripts": { | 27 | "scripts": { |
@@ -41,7 +41,7 @@ | |||
41 | "@rollup/plugin-node-resolve": "^7.1.1", | 41 | "@rollup/plugin-node-resolve": "^7.1.1", |
42 | "@types/node": "^12.12.29", | 42 | "@types/node": "^12.12.29", |
43 | "@types/node-fetch": "^2.5.5", | 43 | "@types/node-fetch": "^2.5.5", |
44 | "@types/vscode": "^1.42.0", | 44 | "@types/vscode": "^1.43.0", |
45 | "@typescript-eslint/eslint-plugin": "^2.22.0", | 45 | "@typescript-eslint/eslint-plugin": "^2.22.0", |
46 | "@typescript-eslint/parser": "^2.22.0", | 46 | "@typescript-eslint/parser": "^2.22.0", |
47 | "eslint": "^6.8.0", | 47 | "eslint": "^6.8.0", |
@@ -224,6 +224,11 @@ | |||
224 | "default": true, | 224 | "default": true, |
225 | "description": "Whether to ask for permission before downloading any files from the Internet" | 225 | "description": "Whether to ask for permission before downloading any files from the Internet" |
226 | }, | 226 | }, |
227 | "rust-analyzer.additionalOutDirs": { | ||
228 | "type": "object", | ||
229 | "default": {}, | ||
230 | "markdownDescription": "Fine grained controls for OUT_DIR `env!(\"OUT_DIR\")` variable. e.g. `{\"foo\":\"/path/to/foo\"}`, " | ||
231 | }, | ||
227 | "rust-analyzer.serverPath": { | 232 | "rust-analyzer.serverPath": { |
228 | "type": [ | 233 | "type": [ |
229 | "null", | 234 | "null", |
@@ -256,7 +261,7 @@ | |||
256 | "rust-analyzer.cargo-watch.enable": { | 261 | "rust-analyzer.cargo-watch.enable": { |
257 | "type": "boolean", | 262 | "type": "boolean", |
258 | "default": true, | 263 | "default": true, |
259 | "markdownDescription": "Run `cargo check` for diagnostics on save" | 264 | "markdownDescription": "Run specified `cargo-watch` command for diagnostics on save" |
260 | }, | 265 | }, |
261 | "rust-analyzer.cargo-watch.arguments": { | 266 | "rust-analyzer.cargo-watch.arguments": { |
262 | "type": "array", | 267 | "type": "array", |
@@ -307,12 +312,17 @@ | |||
307 | "exclusiveMinimum": true, | 312 | "exclusiveMinimum": true, |
308 | "description": "Number of syntax trees rust-analyzer keeps in memory" | 313 | "description": "Number of syntax trees rust-analyzer keeps in memory" |
309 | }, | 314 | }, |
310 | "rust-analyzer.displayInlayHints": { | 315 | "rust-analyzer.inlayHints.typeHints": { |
316 | "type": "boolean", | ||
317 | "default": true, | ||
318 | "description": "Whether to show inlay type hints" | ||
319 | }, | ||
320 | "rust-analyzer.inlayHints.parameterHints": { | ||
311 | "type": "boolean", | 321 | "type": "boolean", |
312 | "default": true, | 322 | "default": true, |
313 | "description": "Display additional type and parameter information in the editor" | 323 | "description": "Whether to show function parameter name inlay hints at the call site" |
314 | }, | 324 | }, |
315 | "rust-analyzer.maxInlayHintLength": { | 325 | "rust-analyzer.inlayHints.maxLength": { |
316 | "type": [ | 326 | "type": [ |
317 | "null", | 327 | "null", |
318 | "integer" | 328 | "integer" |
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 540f7c9ea..d65454275 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -29,17 +29,24 @@ export async function createClient(config: Config, serverPath: string): Promise< | |||
29 | initializationOptions: { | 29 | initializationOptions: { |
30 | publishDecorations: !config.highlightingSemanticTokens, | 30 | publishDecorations: !config.highlightingSemanticTokens, |
31 | lruCapacity: config.lruCapacity, | 31 | lruCapacity: config.lruCapacity, |
32 | maxInlayHintLength: config.maxInlayHintLength, | 32 | |
33 | inlayHintsType: config.inlayHints.typeHints, | ||
34 | inlayHintsParameter: config.inlayHints.parameterHints, | ||
35 | inlayHintsMaxLength: config.inlayHints.maxLength, | ||
36 | |||
33 | cargoWatchEnable: cargoWatchOpts.enable, | 37 | cargoWatchEnable: cargoWatchOpts.enable, |
34 | cargoWatchArgs: cargoWatchOpts.arguments, | 38 | cargoWatchArgs: cargoWatchOpts.arguments, |
35 | cargoWatchCommand: cargoWatchOpts.command, | 39 | cargoWatchCommand: cargoWatchOpts.command, |
36 | cargoWatchAllTargets: cargoWatchOpts.allTargets, | 40 | cargoWatchAllTargets: cargoWatchOpts.allTargets, |
41 | |||
37 | excludeGlobs: config.excludeGlobs, | 42 | excludeGlobs: config.excludeGlobs, |
38 | useClientWatching: config.useClientWatching, | 43 | useClientWatching: config.useClientWatching, |
39 | featureFlags: config.featureFlags, | 44 | featureFlags: config.featureFlags, |
45 | additionalOutDirs: config.additionalOutDirs, | ||
40 | withSysroot: config.withSysroot, | 46 | withSysroot: config.withSysroot, |
41 | cargoFeatures: config.cargoFeatures, | 47 | cargoFeatures: config.cargoFeatures, |
42 | rustfmtArgs: config.rustfmtArgs, | 48 | rustfmtArgs: config.rustfmtArgs, |
49 | vscodeLldb: vscode.extensions.getExtension("vadimcn.vscode-lldb") != null, | ||
43 | }, | 50 | }, |
44 | traceOutputChannel, | 51 | traceOutputChannel, |
45 | middleware: { | 52 | middleware: { |
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 06b513466..357155163 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts | |||
@@ -62,6 +62,26 @@ export function runSingle(ctx: Ctx): Cmd { | |||
62 | }; | 62 | }; |
63 | } | 63 | } |
64 | 64 | ||
65 | export function debugSingle(ctx: Ctx): Cmd { | ||
66 | return async (config: ra.Runnable) => { | ||
67 | const editor = ctx.activeRustEditor; | ||
68 | if (!editor) return; | ||
69 | |||
70 | const debugConfig = { | ||
71 | type: "lldb", | ||
72 | request: "launch", | ||
73 | name: config.label, | ||
74 | cargo: { | ||
75 | args: config.args, | ||
76 | }, | ||
77 | args: config.extraArgs, | ||
78 | cwd: config.cwd | ||
79 | }; | ||
80 | |||
81 | return vscode.debug.startDebugging(undefined, debugConfig); | ||
82 | }; | ||
83 | } | ||
84 | |||
65 | class RunnableQuickPick implements vscode.QuickPickItem { | 85 | class RunnableQuickPick implements vscode.QuickPickItem { |
66 | public label: string; | 86 | public label: string; |
67 | public description?: string | undefined; | 87 | public description?: string | undefined; |
@@ -87,7 +107,7 @@ function createTask(spec: ra.Runnable): vscode.Task { | |||
87 | type: 'cargo', | 107 | type: 'cargo', |
88 | label: spec.label, | 108 | label: spec.label, |
89 | command: spec.bin, | 109 | command: spec.bin, |
90 | args: spec.args, | 110 | args: spec.extraArgs ? [...spec.args, '--', ...spec.extraArgs] : spec.args, |
91 | env: spec.env, | 111 | env: spec.env, |
92 | }; | 112 | }; |
93 | 113 | ||
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index b72206d3c..6db073bec 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -5,6 +5,12 @@ import { log } from "./util"; | |||
5 | 5 | ||
6 | const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; | 6 | const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; |
7 | 7 | ||
8 | export interface InlayHintOptions { | ||
9 | typeHints: boolean; | ||
10 | parameterHints: boolean; | ||
11 | maxLength: number | null; | ||
12 | } | ||
13 | |||
8 | export interface CargoWatchOptions { | 14 | export interface CargoWatchOptions { |
9 | enable: boolean; | 15 | enable: boolean; |
10 | arguments: string[]; | 16 | arguments: string[]; |
@@ -22,7 +28,8 @@ export class Config { | |||
22 | private static readonly requiresReloadOpts = [ | 28 | private static readonly requiresReloadOpts = [ |
23 | "cargoFeatures", | 29 | "cargoFeatures", |
24 | "cargo-watch", | 30 | "cargo-watch", |
25 | "highlighting.semanticTokens" | 31 | "highlighting.semanticTokens", |
32 | "inlayHints", | ||
26 | ] | 33 | ] |
27 | .map(opt => `${Config.rootSection}.${opt}`); | 34 | .map(opt => `${Config.rootSection}.${opt}`); |
28 | 35 | ||
@@ -149,11 +156,17 @@ export class Config { | |||
149 | get highlightingOn() { return this.cfg.get("highlightingOn") as boolean; } | 156 | get highlightingOn() { return this.cfg.get("highlightingOn") as boolean; } |
150 | get rainbowHighlightingOn() { return this.cfg.get("rainbowHighlightingOn") as boolean; } | 157 | get rainbowHighlightingOn() { return this.cfg.get("rainbowHighlightingOn") as boolean; } |
151 | get lruCapacity() { return this.cfg.get("lruCapacity") as null | number; } | 158 | get lruCapacity() { return this.cfg.get("lruCapacity") as null | number; } |
152 | get displayInlayHints() { return this.cfg.get("displayInlayHints") as boolean; } | 159 | get inlayHints(): InlayHintOptions { |
153 | get maxInlayHintLength() { return this.cfg.get("maxInlayHintLength") as number; } | 160 | return { |
161 | typeHints: this.cfg.get("inlayHints.typeHints") as boolean, | ||
162 | parameterHints: this.cfg.get("inlayHints.parameterHints") as boolean, | ||
163 | maxLength: this.cfg.get("inlayHints.maxLength") as null | number, | ||
164 | }; | ||
165 | } | ||
154 | get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; } | 166 | get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; } |
155 | get useClientWatching() { return this.cfg.get("useClientWatching") as boolean; } | 167 | get useClientWatching() { return this.cfg.get("useClientWatching") as boolean; } |
156 | get featureFlags() { return this.cfg.get("featureFlags") as Record<string, boolean>; } | 168 | get featureFlags() { return this.cfg.get("featureFlags") as Record<string, boolean>; } |
169 | get additionalOutDirs() { return this.cfg.get("additionalOutDirs") as Record<string, string>; } | ||
157 | get rustfmtArgs() { return this.cfg.get("rustfmtArgs") as string[]; } | 170 | get rustfmtArgs() { return this.cfg.get("rustfmtArgs") as string[]; } |
158 | 171 | ||
159 | get cargoWatchOptions(): CargoWatchOptions { | 172 | get cargoWatchOptions(): CargoWatchOptions { |
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts index e1a82e03e..b19b09ad5 100644 --- a/editors/code/src/inlay_hints.ts +++ b/editors/code/src/inlay_hints.ts | |||
@@ -10,7 +10,7 @@ export function activateInlayHints(ctx: Ctx) { | |||
10 | const maybeUpdater = { | 10 | const maybeUpdater = { |
11 | updater: null as null | HintsUpdater, | 11 | updater: null as null | HintsUpdater, |
12 | onConfigChange() { | 12 | onConfigChange() { |
13 | if (!ctx.config.displayInlayHints) { | 13 | if (!ctx.config.inlayHints.typeHints && !ctx.config.inlayHints.parameterHints) { |
14 | return this.dispose(); | 14 | return this.dispose(); |
15 | } | 15 | } |
16 | if (!this.updater) this.updater = new HintsUpdater(ctx); | 16 | if (!this.updater) this.updater = new HintsUpdater(ctx); |
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index ecf53cf77..e01c89cc7 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -83,6 +83,7 @@ export async function activate(context: vscode.ExtensionContext) { | |||
83 | 83 | ||
84 | // Internal commands which are invoked by the server. | 84 | // Internal commands which are invoked by the server. |
85 | ctx.registerCommand('runSingle', commands.runSingle); | 85 | ctx.registerCommand('runSingle', commands.runSingle); |
86 | ctx.registerCommand('debugSingle', commands.debugSingle); | ||
86 | ctx.registerCommand('showReferences', commands.showReferences); | 87 | ctx.registerCommand('showReferences', commands.showReferences); |
87 | ctx.registerCommand('applySourceChange', commands.applySourceChange); | 88 | ctx.registerCommand('applySourceChange', commands.applySourceChange); |
88 | ctx.registerCommand('selectAndApplySourceChange', commands.selectAndApplySourceChange); | 89 | ctx.registerCommand('selectAndApplySourceChange', commands.selectAndApplySourceChange); |
diff --git a/editors/code/src/rust-analyzer-api.ts b/editors/code/src/rust-analyzer-api.ts index 6ad93715f..9846f7343 100644 --- a/editors/code/src/rust-analyzer-api.ts +++ b/editors/code/src/rust-analyzer-api.ts | |||
@@ -80,13 +80,12 @@ export interface Runnable { | |||
80 | label: string; | 80 | label: string; |
81 | bin: string; | 81 | bin: string; |
82 | args: Vec<string>; | 82 | args: Vec<string>; |
83 | extraArgs: Vec<string>; | ||
83 | env: FxHashMap<string, string>; | 84 | env: FxHashMap<string, string>; |
84 | cwd: Option<string>; | 85 | cwd: Option<string>; |
85 | } | 86 | } |
86 | export const runnables = request<RunnablesParams, Vec<Runnable>>("runnables"); | 87 | export const runnables = request<RunnablesParams, Vec<Runnable>>("runnables"); |
87 | 88 | ||
88 | |||
89 | |||
90 | export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint; | 89 | export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint; |
91 | 90 | ||
92 | export namespace InlayHint { | 91 | export namespace InlayHint { |