Closed sou-chon closed 1 year ago
In the past the inlay hints comes with variable names
Yes, this has been removed.
The previous implementation of inlay hint was not in LSP, rust-analyzer supported this in its protocol and coc-rust-analyzer supports this too, this was the past.
From LSP 3.17, inlay hint has been added to LSP, rust-analyzer changed to follow official LSP. But the official inlay hint protocol is a little different from rust-analyzer's own.
The old protocol, rust-analyzer returns a hint in this:
export namespace InlayHint {
export const enum Kind {
TypeHint = 'TypeHint',
ParamHint = 'ParameterHint',
ChainingHint = 'ChainingHint',
}
interface Common {
range: lc.Range;
label: string;
}
export type TypeHint = Common & { kind: Kind.TypeHint };
export type ParamHint = Common & { kind: Kind.ParamHint };
export type ChainingHint = Common & { kind: Kind.ChainingHint };
}
Note the Common.range, rust-analyzer told you the range text and its hint label. coc-rust-analyzer uses the range to substring the variable name to display.
The LSP:
export declare type InlayHint = {
position: Position;
label: string | InlayHintLabelPart[];
kind?: InlayHintKind;
textEdits?: TextEdit[];
tooltip?: string | MarkupContent;
paddingLeft?: boolean;
paddingRight?: boolean;
data?: LSPAny;
};
There's no range now, only a position that hint began. We can't get variable now.
allow the inlay hint be inserted into the code
Use vim, yes, nvim doesn't support this.
Hi I am loving the inlay hints but they only come at the end of the line instead of being inserted into the code itself so it's really hard to see which variable it's referring to (see screenshot). In the past the inlay hints comes with variable names like
foo: i32
. Is there an option where I can enable variable name display? or to allow the inlay hint be inserted into the code and not at the end of the line?thanks
What's the output of
:CocInfo
What's the output of
:CocCommand rust-analyzer.serverVersion
0.3.1309-standaloneWhat's your coc-rust-analyzer version? You can get it from
:CocList extensions
0.70.0