-
Notifications
You must be signed in to change notification settings - Fork 29.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide API to return formatted content from suggest and parameter hints #11877
Comments
@jrieken Not sure whether we already have an issue for this. |
API wise, I'd suggest the following non breaking changes: Whats new are the export class CompletionItem {
label: string; // leave as is... Otherwise things get complicated with the completion highlights
detail: string | MarkedString[];
documentation: string | MarkedString[];
/// ...
}
export class ParameterInformation {
label: string; // no change ?
documentation: string | MarkedString[];
}
export class SignatureInformation {
label: string; // no change ?
documentation: string | MarkedString[];
} The following additions are optional, but IMO nice for consistency. For the hover constructor I'd suggest to break the behaviour and release-note that, or and add a new one like shown below. export class Hover {
contents: string | MarkedString[]; // adding string for plain text
/** deprecated: Use constructor(range, string | MarkedString[]) instead.*/
constructor(contents: MarkedString | MarkedString[], range?: Range); // no change.
constructor(range: Range, contents: string | MarkedString[]); // order changed, range can be null or undefined
} For DecorationOptions, we can leave it as is or I suggest to do the following change which fix another API issue with the decoration API (which is not urgent, but just came up recently) export interface DecorationOptions {
/** deprecated, use textHoverContents or gutterHoverContents instead */
hoverMessage?: MarkedString | MarkedString[];
textHoverContents?: string | MarkedString[];
gutterHoverContents?: string | MarkedString[];
} |
part of microsoft#11877 This allows marked strings to be used in the `detail` and `documentation` field of completion items. I've tried to preseve the existing behavior as much as possible with this change. The new rendering will only be applied when an array of marked strings is passed in
With @ramya-rao-a's work on the completion view, the lack of syntax coloring / markdown in completion item documentation is much more noticeable. Can we revisit this? Since #19779 wasn't considered the right approach, what are thoughts on alternatives? @joaomoreno mentioned a export class CompletionItem {
label: string;
detail?: string;
richDetail?: MarkedString[]; // If present, would be used in place of `detail`. Would need a better name
documentation?: string;
richDocumentation?: MarkedString[]
...
} The would keep the API backwards compatible but it's still ugly. Other thoughts? |
Idea is to use a new type that subsumes |
Note that any change also needs to go into the language server protocol and it would be nice if we keep the APIs as similar as possible (not a must, but it's a better story). FYI @dbaeumer The feedback we got from the snippet work was that we should not change the shape of property types (e.g. from In this case it would be new optional fields 'detailFormat' and 'documentationFormat` on the completion item. Values are of a number enum: 'PlainText' or 'Markdown'. The default would be 'PlainText'. |
This will be enabled with the work we are doing for #29076 |
@jrieken Are you already looking into updating Suggest and/or Parameter hint to use |
This is the issue to do that and I have scheduled it for September. |
…one place for keeping the renderer options, #11877
Update internal api, update rendering of suggestion details, tweak shared renderer
The API is there, the UI is adopted, it is now up to the languages to return completion items and signature help that uses it. fyi @mjbvz |
Take the following snippet:
Here's how it looks in different widgets:
Hover
Suggest
Parameter hints
Widgets look now somewhat aligned, since #2330. Their contents, on the other hand, could be a bit more.
Hover looks great, since at some point we provided the possibility of returning
MarkedString
through the API.Both suggest and parameter hints lack that and look pretty pale in comparison.
We got to find a way to advance the API allowing users to return formatted content from certain API calls without bloating the API too much.
The text was updated successfully, but these errors were encountered: