hrsh7th / cmp-nvim-lsp-signature-help

cmp-nvim-lsp-signature-help
637 stars 26 forks source link

Incorrectly rendered markdown docstring #33

Open zhiyozhao opened 1 year ago

zhiyozhao commented 1 year ago

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 commented 1 year ago

Hey,

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

nyngwang commented 1 year ago

35 seems like a similar issue?

Xamnalim commented 5 months ago

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 commented 3 months ago

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 commented 3 months ago

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

image

image

aggonis commented 3 months ago

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

pwang2 commented 3 months ago

@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 commented 2 months ago

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 commented 2 months ago

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

You can reference the code here and add in your init

https://github.com/hrsh7th/nvim-cmp/issues/1699#issuecomment-1738132283

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