diff options
author | Steffen Lyngbaek <[email protected]> | 2020-03-10 07:55:46 +0000 |
---|---|---|
committer | Steffen Lyngbaek <[email protected]> | 2020-03-10 21:33:45 +0000 |
commit | e98aff109a1c4bda6a05f16981898425c302aa0c (patch) | |
tree | bad52598c5638a81af9066592913bdfcdcb639fa /editors/code | |
parent | 0714a065d578e8b22b0451bfc64378c875fe858f (diff) |
Parameter inlay hint separate from variable type inlay? #2876
Add setting to allow enabling either type inlay hints or parameter
inlay hints or both. Group the the max inlay hint length option
into the object.
- Add a new type for the inlayHint options.
- Add tests to ensure the inlays don't happen on the server side
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/package.json | 20 | ||||
-rw-r--r-- | editors/code/src/client.ts | 2 | ||||
-rw-r--r-- | editors/code/src/config.ts | 13 | ||||
-rw-r--r-- | editors/code/src/inlay_hints.ts | 2 |
4 files changed, 29 insertions, 8 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index 512885454..6f2275062 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -307,12 +307,24 @@ | |||
307 | "exclusiveMinimum": true, | 307 | "exclusiveMinimum": true, |
308 | "description": "Number of syntax trees rust-analyzer keeps in memory" | 308 | "description": "Number of syntax trees rust-analyzer keeps in memory" |
309 | }, | 309 | }, |
310 | "rust-analyzer.displayInlayHints": { | 310 | "rust-analyzer.inlayHintOpts.displayType": { |
311 | "type": "boolean", | 311 | "type": "string", |
312 | "default": true, | 312 | "enum": [ |
313 | "off", | ||
314 | "typeHints", | ||
315 | "parameterHints", | ||
316 | "full" | ||
317 | ], | ||
318 | "enumDescriptions": [ | ||
319 | "No type inlay hints", | ||
320 | "Type inlays hints only", | ||
321 | "Parameter inlays hints only", | ||
322 | "All inlay hints types" | ||
323 | ], | ||
324 | "default": "full", | ||
313 | "description": "Display additional type and parameter information in the editor" | 325 | "description": "Display additional type and parameter information in the editor" |
314 | }, | 326 | }, |
315 | "rust-analyzer.maxInlayHintLength": { | 327 | "rust-analyzer.inlayHintOpts.maxLength": { |
316 | "type": [ | 328 | "type": [ |
317 | "null", | 329 | "null", |
318 | "integer" | 330 | "integer" |
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 540f7c9ea..ac4417c61 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -29,7 +29,7 @@ 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 | inlayHintOpts: config.inlayHintOpts, |
33 | cargoWatchEnable: cargoWatchOpts.enable, | 33 | cargoWatchEnable: cargoWatchOpts.enable, |
34 | cargoWatchArgs: cargoWatchOpts.arguments, | 34 | cargoWatchArgs: cargoWatchOpts.arguments, |
35 | cargoWatchCommand: cargoWatchOpts.command, | 35 | cargoWatchCommand: cargoWatchOpts.command, |
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index b72206d3c..5acce0752 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -5,6 +5,11 @@ 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 | displayType: string; | ||
10 | maxLength: number; | ||
11 | } | ||
12 | |||
8 | export interface CargoWatchOptions { | 13 | export interface CargoWatchOptions { |
9 | enable: boolean; | 14 | enable: boolean; |
10 | arguments: string[]; | 15 | arguments: string[]; |
@@ -149,8 +154,12 @@ export class Config { | |||
149 | get highlightingOn() { return this.cfg.get("highlightingOn") as boolean; } | 154 | get highlightingOn() { return this.cfg.get("highlightingOn") as boolean; } |
150 | get rainbowHighlightingOn() { return this.cfg.get("rainbowHighlightingOn") as boolean; } | 155 | get rainbowHighlightingOn() { return this.cfg.get("rainbowHighlightingOn") as boolean; } |
151 | get lruCapacity() { return this.cfg.get("lruCapacity") as null | number; } | 156 | get lruCapacity() { return this.cfg.get("lruCapacity") as null | number; } |
152 | get displayInlayHints() { return this.cfg.get("displayInlayHints") as boolean; } | 157 | get inlayHintOpts(): InlayHintOptions { |
153 | get maxInlayHintLength() { return this.cfg.get("maxInlayHintLength") as number; } | 158 | return { |
159 | displayType: this.cfg.get("inlayHintOpts.displayType") as string, | ||
160 | maxLength: this.cfg.get("inlayHintOpts.maxLength") as number, | ||
161 | }; | ||
162 | } | ||
154 | get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; } | 163 | get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; } |
155 | get useClientWatching() { return this.cfg.get("useClientWatching") as boolean; } | 164 | get useClientWatching() { return this.cfg.get("useClientWatching") as boolean; } |
156 | get featureFlags() { return this.cfg.get("featureFlags") as Record<string, boolean>; } | 165 | get featureFlags() { return this.cfg.get("featureFlags") as Record<string, boolean>; } |
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts index e1a82e03e..8d291406d 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.inlayHintOpts.displayType === 'off') { |
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); |