autozimu / LanguageClient-neovim

Language Server Protocol (LSP) support for vim and neovim.
MIT License
3.55k stars 273 forks source link

The comment in hover adds blackslash and emptylines automatically. #1146

Closed RunningIkkyu closed 3 years ago

RunningIkkyu commented 3 years ago


health#LanguageClient#check
========================================================================
  - OK: binary found: /home/xxx/.vim/plugged/LanguageClient-neovim/bin/languageclient
  - OK: languageclient 0.1.160
  - OK: Floating window is supported and will be used for hover

Info

plugin version: Latest. Neovim version: NVIM v0.5.0 System: linux 5.6.19-2-MANJARO

Describe the bug

The text shows in hover got bad format, the hover will add upexpected backslash and empty lines automatically.

Here is my code:

// Proxying IE, Refer to [TS29244 8.2.97 Proxying]
//
// The Proxying IE shall be encoded as shown in Figure 8.2.97-1. It specifies
// if responding to Address Resolution Protocol (ARP) (see IETF RFC 826 [32])
// and / or IPv6 Neighbour Solicitation (see IETF RFC 4861 [33]) as specified
// in  clause 5.6.10.2 of 3GPP TS 23.501 [28], functionality for the Ethernet
// PDUs is performed in UPF.
//
//                                         Bits
//  Octets       8       7       6       5       4       3       2       1
//           +----------------------------------------------------------------+
//  1 to 2   |                   Type = 137(decimal)                          |
//           |----------------------------------------------------------------|
//  3 to 4   |                      Length = n                                |
//           |----------------------------------------------------------------|
//    5      |             Spare                             |  INS  |  ARP   |
//           |----------------------------------------------------------------|
// 6 to (n+4)|   These octets(s) is/are present only if explicitly specified  |
//           +----------------------------------------------------------------+
//
// The following flags are coded within Octet 5:
//
// - Bit 1 – ARP: If this bit is set to "1", then responding ARP is performed
//   in UPF based on local cache information.
//
// - Bit 2 – INS: If this bit is set to "1", then responding to IPv6
//   Neighbour Solicitation is performed in UPF based on
//
// - Bit 3 to 8 – spare and reserved for future use. 8.2.98 Ethernet Filter ID
//
type Proxying struct {
    Arp bool
    Ins bool
}

And here is what I got in popup:


 Proxying IE, Refer to \[TS29244 8\.2\.97 Proxying\]

 The Proxying IE shall be encoded as shown in Figure 8\.2\.97\-1\. It specifies
 if responding to Address Resolution Protocol \(ARP\) \(see IETF RFC 826 \[32\]\)
 and \/ or IPv6 Neighbour Solicitation \(see IETF RFC 4861 \[33\]\) as specified
 in  clause 5\.6\.10\.2 of 3GPP TS 23\.501 \[28\], functionality for the Ethernet
 PDUs is performed in UPF\.

                                            Bits

     Octets       8       7       6       5       4       3       2       1

              +----------------------------------------------------------------+

     1 to 2   |                   Type = 137(decimal)                          |

              |----------------------------------------------------------------|

     3 to 4   |                      Length = n                                |

              |----------------------------------------------------------------|

       5      |             Spare                             |  INS  |  ARP   |

              |----------------------------------------------------------------|

 6 to \(n\+4\)\|   These octets\(s\) is\/are present only if explicitly specified  \|

     +----------------------------------------------------------------+

 The following flags are coded within Octet 5\:

 \- Bit 1 – ARP\: If this bit is set to \"1\", then responding ARP is performed

     in UPF based on local cache information.

 \- Bit 2 – INS\: If this bit is set to \"1\", then responding to IPv6

     Neighbour Solicitation is performed in UPF based on

 \- Bit 3 to 8 – spare and reserved for future use\. 8\.2\.98 Ethernet Filter ID

How to show raw comments in the hover?

Environment

Plug 'autozimu/LanguageClient-neovim', { \ 'branch': 'next', \ 'do': 'bash install.sh', \ }

call plug#end()

let g:LanguageClient_serverCommands = { \ 'go': ['gopls'] \ }



- Language server link and version: [`golang.org/x/tools/gopls v0.5.3`](https://github.com/golang/tools/tree/master/gopls)

## To Reproduce

Steps to reproduce the behavior:

- Install LanguageClient corrently.
- Create a Go file and paste the code above.
- Move the cursor to the name of struct : `Proxying`
- Enter `:call LanguageClient#textDocument_hover()`                                                                                                                                                   

## Current behavior

The comment shows in hover adds blackslash and emptylines automatically.

## Expected behavior

Show the raw contents of comment in the hover. 

## Screenshots

Here is the code:

![Code](https://user-images.githubusercontent.com/31848542/99339112-87ac9b00-28c0-11eb-805d-bf7664394b5d.png)

And the hover shows:

![截图录屏_选择区域_20201117103446](https://user-images.githubusercontent.com/31848542/99339155-95fab700-28c0-11eb-8ade-bb3b70da8861.png)
martskins commented 3 years ago

I think what you are seeing is due to the server sending the documentation for that as markdown. I'm not sure if there's anything you can do to convince the server that that is not markdown, but if you want to get the raw text every time you can configure that with this:

let g:LanguageClient_preferredMarkupKind: ['plaintext', 'markdown']

That tells the server that you prefer plaintext over markdown. Setting only plaintext should work as well.

RunningIkkyu commented 3 years ago

@martskins Thank you so much, this solved my probelm:

let g:LanguageClient_preferredMarkupKind = ['plaintext', 'markdown']