From e98aff109a1c4bda6a05f16981898425c302aa0c Mon Sep 17 00:00:00 2001 From: Steffen Lyngbaek Date: Tue, 10 Mar 2020 00:55:46 -0700 Subject: 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 --- editors/code/src/client.ts | 2 +- editors/code/src/config.ts | 13 +++++++++++-- editors/code/src/inlay_hints.ts | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'editors/code/src') 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< initializationOptions: { publishDecorations: !config.highlightingSemanticTokens, lruCapacity: config.lruCapacity, - maxInlayHintLength: config.maxInlayHintLength, + inlayHintOpts: config.inlayHintOpts, cargoWatchEnable: cargoWatchOpts.enable, cargoWatchArgs: cargoWatchOpts.arguments, 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"; const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; +export interface InlayHintOptions { + displayType: string; + maxLength: number; +} + export interface CargoWatchOptions { enable: boolean; arguments: string[]; @@ -149,8 +154,12 @@ export class Config { get highlightingOn() { return this.cfg.get("highlightingOn") as boolean; } get rainbowHighlightingOn() { return this.cfg.get("rainbowHighlightingOn") as boolean; } get lruCapacity() { return this.cfg.get("lruCapacity") as null | number; } - get displayInlayHints() { return this.cfg.get("displayInlayHints") as boolean; } - get maxInlayHintLength() { return this.cfg.get("maxInlayHintLength") as number; } + get inlayHintOpts(): InlayHintOptions { + return { + displayType: this.cfg.get("inlayHintOpts.displayType") as string, + maxLength: this.cfg.get("inlayHintOpts.maxLength") as number, + }; + } get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; } get useClientWatching() { return this.cfg.get("useClientWatching") as boolean; } get featureFlags() { return this.cfg.get("featureFlags") as Record; } 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) { const maybeUpdater = { updater: null as null | HintsUpdater, onConfigChange() { - if (!ctx.config.displayInlayHints) { + if (ctx.config.inlayHintOpts.displayType === 'off') { return this.dispose(); } if (!this.updater) this.updater = new HintsUpdater(ctx); -- cgit v1.2.3 From cfb48df149bfa8a15b113b1a252598457a4ea392 Mon Sep 17 00:00:00 2001 From: Steffen Lyngbaek Date: Tue, 10 Mar 2020 11:21:56 -0700 Subject: Address Issues from Github - Updated naming of config - Define struct in ra_ide and use remote derive in rust-analyzer/config - Make inlayConfig type more flexible to support more future types - Remove constructor only used in tests --- editors/code/src/config.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'editors/code/src') diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 5acce0752..b26bf10da 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -27,7 +27,9 @@ export class Config { private static readonly requiresReloadOpts = [ "cargoFeatures", "cargo-watch", - "highlighting.semanticTokens" + "highlighting.semanticTokens", + "inlayHintOpts.maxLength", + "inlayHintOpts.displayType", ] .map(opt => `${Config.rootSection}.${opt}`); -- cgit v1.2.3 From 58248e24cd45adcbfd7bfd00e1487df196b4a8c6 Mon Sep 17 00:00:00 2001 From: Steffen Lyngbaek Date: Wed, 11 Mar 2020 20:14:39 -0700 Subject: Switch from Vec to object with props - Instead of a single object type, use several individual nested types to allow toggling from the settings GUI - Remove unused struct definitions - Install and test that the toggles work --- editors/code/src/client.ts | 2 +- editors/code/src/config.ts | 13 +++++++------ editors/code/src/inlay_hints.ts | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index ac4417c61..3b8ea6f77 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< initializationOptions: { publishDecorations: !config.highlightingSemanticTokens, lruCapacity: config.lruCapacity, - inlayHintOpts: config.inlayHintOpts, + inlayHints: config.inlayHints, cargoWatchEnable: cargoWatchOpts.enable, cargoWatchArgs: cargoWatchOpts.arguments, cargoWatchCommand: cargoWatchOpts.command, diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index b26bf10da..2668c9640 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -6,7 +6,8 @@ import { log } from "./util"; const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; export interface InlayHintOptions { - displayType: string; + typeHints: boolean; + parameterHints: boolean; maxLength: number; } @@ -28,8 +29,7 @@ export class Config { "cargoFeatures", "cargo-watch", "highlighting.semanticTokens", - "inlayHintOpts.maxLength", - "inlayHintOpts.displayType", + "inlayHints", ] .map(opt => `${Config.rootSection}.${opt}`); @@ -156,10 +156,11 @@ export class Config { get highlightingOn() { return this.cfg.get("highlightingOn") as boolean; } get rainbowHighlightingOn() { return this.cfg.get("rainbowHighlightingOn") as boolean; } get lruCapacity() { return this.cfg.get("lruCapacity") as null | number; } - get inlayHintOpts(): InlayHintOptions { + get inlayHints(): InlayHintOptions { return { - displayType: this.cfg.get("inlayHintOpts.displayType") as string, - maxLength: this.cfg.get("inlayHintOpts.maxLength") as number, + typeHints: this.cfg.get("inlayHints.typeHints") as boolean, + parameterHints: this.cfg.get("inlayHints.parameterHints") as boolean, + maxLength: this.cfg.get("inlayHints.maxLength") as number, }; } get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; } diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts index 8d291406d..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) { const maybeUpdater = { updater: null as null | HintsUpdater, onConfigChange() { - if (ctx.config.inlayHintOpts.displayType === 'off') { + if (!ctx.config.inlayHints.typeHints && !ctx.config.inlayHints.parameterHints) { return this.dispose(); } if (!this.updater) this.updater = new HintsUpdater(ctx); -- cgit v1.2.3 From a153b9087520012b5f815b4df6c3657d490b30c8 Mon Sep 17 00:00:00 2001 From: Steffen Lyngbaek Date: Thu, 12 Mar 2020 08:43:07 -0700 Subject: Make maxLength nullable again --- editors/code/src/config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 2668c9640..c3b3ecabf 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -8,7 +8,7 @@ const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; export interface InlayHintOptions { typeHints: boolean; parameterHints: boolean; - maxLength: number; + maxLength: number | null; } export interface CargoWatchOptions { @@ -160,7 +160,7 @@ export class Config { return { typeHints: this.cfg.get("inlayHints.typeHints") as boolean, parameterHints: this.cfg.get("inlayHints.parameterHints") as boolean, - maxLength: this.cfg.get("inlayHints.maxLength") as number, + maxLength: this.cfg.get("inlayHints.maxLength") as null | number, }; } get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; } -- cgit v1.2.3