Skip to content
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

Incorrectly rendered markdown docstring #33

Open
zhiyozhao opened this issue Apr 13, 2023 · 9 comments
Open

Incorrectly rendered markdown docstring #33

zhiyozhao opened this issue Apr 13, 2023 · 9 comments

Comments

@zhiyozhao
Copy link

As shown in the figure below:

This the the completion from nvim-cmp + cmp-nvim-lsp:
Screenshot 2023-04-13 at 21 29 35

While this is the signatur help of the same function from nvim-cmp + cmp-nvim-lsp-signature-help:
Screenshot 2023-04-13 at 21 02 45

@tillw33
Copy link

tillw33 commented May 23, 2023

Hey,

im facing the same issue, did you find any solution on this?

@nyngwang
Copy link

nyngwang commented Jun 1, 2023

#35 seems like a similar issue?

@Xamnalim
Copy link

Xamnalim commented Jun 4, 2024

Same issue. cmp-nvim-lsp renders correctly (lua snippet is nicely rendered with syntax highlighting):
image
nvim_lsp_signature_help doesn't (lua snippet not rendered):
image

@aggonis
Copy link

aggonis commented Aug 23, 2024

same issue here as well:
image

even though hovering over doesn't run into the same issue:
image

@hrsh7th do you know why this might happen?

@pwang2
Copy link

pwang2 commented Aug 25, 2024

Something related can be improved. The markdown code directive is displayed as an empty line.

image

image

@aggonis
Copy link

aggonis commented Aug 28, 2024

@pwang2 what's your formatting function look like for the above?

@pwang2
Copy link

pwang2 commented Aug 29, 2024

@aggonis, same cmp-nvim-lsp.

I also used lspsaga's hover render which is claimed rendered via treesitter. similar result.
https://nvimdev.github.io/lspsaga/hover/#:~:text=Why%3F%20Unlike%20the%20built%2Din%20hover%2C%20vim.lsp.buf.hover%2C%20which%20uses%20regex%20syntax%20to%20render%20markdown%2C%20Lspsaga%20uses%20treesitter.

By default, markdown conceal is automatically enabled which results too many empty lines. My 2 cents here is since it is a markdown renderer and we will not gona edit the file, using the rendered result could make sense.

@kuro337
Copy link

kuro337 commented Sep 10, 2024

Just chipping in as I went through the same issues here - so I'm assuming it's difficult to change because this plugin doesn't modify the documentation we send and it is adjusted in the main code?

Because I examined the floats that open and seems to me like the values passed are removed for the markdown and Code Language from the provided documentation string , so I'm assuming it is being stripped elsewhere?

For example - right before the source.complete callback is called adding a log shows

item: {
  documentation = {
    kind = "markdown",
    value = "```go\nfunc NewFromConfig(cfg aws.Config, optFns ...func(*s3.Options)) *s3.Client\n```"
  },
  filterText = " ",
  insertText = "optFns",
  label = "optFns ...func(*s3.Options)",
  preselect = true,
  word = ""
}

But examining the window content-

Window Content:
func NewFromConfig(cfg aws.Config, optFns ...func(*s3.Options)) *s3.Client

Whereas the floating window for hover (added backslash)

Window Content:
\```go
func s3.NewFromConfig(cfg aws.Config, optFns ...func(*s3.Options)) *s3.Client
\```

Let me know if I am doing anything wrong - but basically my main question would be @hrsh7th - if we add a source and provide values to the complete callback - (referencing the docs) - is it not determinnistic? I'm trying to figure out if the issue is in the code here or if it is because the nvim-cmp plugin and cmp-nvim-lsp-signature-help plugin is sharing some state.

Let me know, would appreciate it - thanks for the awesome plugins :)

@kuro337
Copy link

kuro337 commented Sep 10, 2024

Nevermind - this has nothing to do with cmp's implementation.

You can reference the code here and add in your init

hrsh7th/nvim-cmp#1699 (comment)

To fix the issue of it showing as Text - you can add this to where it returns the label on Line 118

  return {
    label = label,
    filterText = ' ',
    insertText = self:_matchstr(label, [[\k\+]]),
    word = '',
    preselect = true,
    documentation = self:_docs(signature, parameter_index),
    ---
    kind = require('cmp').lsp.CompletionItemKind.Function,  -- add this
  }
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants