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/package.json | 20 ++++++++++++++++---- editors/code/src/client.ts | 2 +- editors/code/src/config.ts | 13 +++++++++++-- editors/code/src/inlay_hints.ts | 2 +- 4 files changed, 29 insertions(+), 8 deletions(-) (limited to 'editors/code') 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 @@ "exclusiveMinimum": true, "description": "Number of syntax trees rust-analyzer keeps in memory" }, - "rust-analyzer.displayInlayHints": { - "type": "boolean", - "default": true, + "rust-analyzer.inlayHintOpts.displayType": { + "type": "string", + "enum": [ + "off", + "typeHints", + "parameterHints", + "full" + ], + "enumDescriptions": [ + "No type inlay hints", + "Type inlays hints only", + "Parameter inlays hints only", + "All inlay hints types" + ], + "default": "full", "description": "Display additional type and parameter information in the editor" }, - "rust-analyzer.maxInlayHintLength": { + "rust-analyzer.inlayHintOpts.maxLength": { "type": [ "null", "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< 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