mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-09 18:02:48 +00:00
Switch from Vec<InlayKind> 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
This commit is contained in:
parent
974ed7155a
commit
58248e24cd
11 changed files with 41 additions and 85 deletions
|
@ -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,
|
||||
|
|
|
@ -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[]; }
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue