0

Markdown content is not showing up in hover content in lsp.

enter image description here

code:

connection.onHover((params) => {
    return {
        contents: [
            {
                language: "lc",
                kind: MarkupKind.Markdown,
                value: `# Header, **bold**`,
            },
        ],
    };
});

But it does shows up when used from vscode extension api

enter image description here

code:

vscode.languages.registerHoverProvider("lc", {
        provideHover(document, position) {
                return new vscode.Hover(
                    new vscode.MarkdownString(`# Header, **bold**`)
                );        
        },
});
Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
Mrinmoy Haloi
  • 143
  • 1
  • 7

1 Answers1

0

I have found the solution to it. I just had to declare a variable with MarkupContent type and then return it.

connection.onHover((params) => {
    const content: MarkupContent = {
        kind: MarkupKind.Markdown,
        value: `**hello**`,
    };

    return {
        contents: content,
    };
});
Mrinmoy Haloi
  • 143
  • 1
  • 7