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

dohover will display backslash-escape for the special characters #97

Closed
kevinhwang91 opened this issue Aug 20, 2020 · 9 comments
Closed
Labels
bug Something isn't working

Comments

@kevinhwang91
Copy link

issue image:
image

@josa42 josa42 added the bug Something isn't working label Aug 25, 2020
@josa42
Copy link
Owner

josa42 commented Aug 25, 2020

I don't think this is caused by coc-go. Looking at the trace, it seems to me that this is an issue with gopls or potentially coc.nvim:

[Trace - 1:33:01 PM] Received response 'textDocument/hover - (31)' in 2ms.
Result: {
    "contents": {
        "kind": "markdown",
        "value": "```go\nfunc sort.Sort(data sort.Interface)\n```\n\n[`sort.Sort` on pkg.go.dev](https://pkg.go.dev/sort#Sort)\n\nSort sorts data\\.\nIt makes one call to data\\.Len to determine n, and O\\(n\\*log\\(n\\)\\) calls to\ndata\\.Less and data\\.Swap\\. The sort is not guaranteed to be stable\\.\n"
    },
    "range": {
        "start": {
            "line": 5,
            "character": 6
        },
        "end": {
            "line": 5,
            "character": 10
        }
    }
}

@kevinhwang91
Copy link
Author

Could coc-go intercept the result and rewrite it properly? vscode-go without this issue.

@flw-cn
Copy link

flw-cn commented Sep 11, 2020

Is there any workaround here? I've encountered more than that, and some &nbsp that have caused alignment problems.

@flw-cn
Copy link

flw-cn commented Sep 13, 2020

I used Wireshark to capture the packets and confirmed that the results returned by gopls are in the correct format.

What else might cause additional backslash?

Content-Length: 349

{"jsonrpc":"2.0","result":{"contents":{"kind":"plaintext","value":"func sort.Sort(data sort.Interface)\nSort sorts data.\nIt makes one call to data.Len to determine n, and O(n*log(n)) calls to\ndata.Less and data.Swap. The sort is not guaranteed to be stable.\n"},"range":{"start":{"line":82,"character":6},"end":{"line":82,"character":10}}},"id":3}

Update:

What is given above is the result of the default parameters, which are actually in JSON format. I noticed that coc/coc-go is requesting results in markdown format, so I redid the test and confirmed that gopls does have this bug:

Content-Length: 445

{"jsonrpc":"2.0","result":{"contents":{"kind":"markdown","value":"```go\nfunc sort.Sort(data sort.Interface)\n```\n\n[`sort.Sort` on pkg.go.dev](https://pkg.go.dev/sort#Sort)\n\nSort sorts data\\.\nIt makes one call to data\\.Len to determine n, and O\\(n\\*log\\(n\\)\\) calls to\ndata\\.Less and data\\.Swap\\. The sort is not guaranteed to be stable\\.\n"},"range":{"start":{"line":82,"character":6},"end":{"line":82,"character":10}}},"id":3}

@chemzqm
Copy link

chemzqm commented Sep 13, 2020

neoclide/coc.nvim#2308

@flw-cn
Copy link

flw-cn commented Sep 13, 2020

@kevinhwang91 You can try Plug “flw-cn/vim-markdown” which is a fork for plasticboy/vim-markdown and it automatically hides the backslash. see PR preservim/vim-markdown#515 to see exactly what it does.

@josa42
Copy link
Owner

josa42 commented Sep 29, 2020

Closing this because it needs to be fixed in coc.nvim

@josa42 josa42 closed this as completed Sep 29, 2020
@anhtumai
Copy link

@kevinhwang91 @josa42 How can you config coc-go to open hover window? When I doHover, it opens new panel with horizon split like this:
image

@josa42
Copy link
Owner

josa42 commented Mar 12, 2023

@anhtumai That is not a coc-go config.

You probably have set hover.target in your coc config to preview, you need to set it to float.

https://github.com/neoclide/coc.nvim/blob/b28b8dc4278f0c68f14b74609d73169c88c97ec4/doc/coc-config.txt#L484-L489

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants