aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/client.ts9
-rw-r--r--editors/code/src/commands/runnables.ts22
-rw-r--r--editors/code/src/config.ts19
-rw-r--r--editors/code/src/inlay_hints.ts2
-rw-r--r--editors/code/src/main.ts1
-rw-r--r--editors/code/src/rust-analyzer-api.ts3
6 files changed, 48 insertions, 8 deletions
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
65export 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
65class RunnableQuickPick implements vscode.QuickPickItem { 85class 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
6const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; 6const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG;
7 7
8export interface InlayHintOptions {
9 typeHints: boolean;
10 parameterHints: boolean;
11 maxLength: number | null;
12}
13
8export interface CargoWatchOptions { 14export 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}
86export const runnables = request<RunnablesParams, Vec<Runnable>>("runnables"); 87export const runnables = request<RunnablesParams, Vec<Runnable>>("runnables");
87 88
88
89
90export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint; 89export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint;
91 90
92export namespace InlayHint { 91export namespace InlayHint {