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

Remove escaping in floating windows #2308

Closed
Lythenas opened this issue Sep 6, 2020 · 8 comments
Closed

Remove escaping in floating windows #2308

Lythenas opened this issue Sep 6, 2020 · 8 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Lythenas
Copy link

Lythenas commented Sep 6, 2020

Is your feature request related to a problem? Please describe.
Remove useless escaping of chars is markdown.

Describe the solution you'd like
Some language servers return escaped characters in markdown. E.g. clangd escapes some characters in text:

[Trace - 11:49:06 AM] Received response 'textDocument/hover - (8)' in 2ms.
Result: {
    "contents": {
        "kind": "markdown",
        "value": "### class `Node`  \n\n---\nWrapper for a \\'TSNode\\'\\. Nodes can be named or anonymous \\(see \\[Named vs Anonymous Nodes\\]\\(https\\:\\/\\/tree\\-sitter\\.github\\.io\\/tree\\-sitter\\/using\\-parsers\\#named\\-vs\\-anonymous\\-nodes\\)\\)\\. We are mostly interested in named nodes\\. Nodes can be null \\(check with is\\_null\\)\\. Note\\: This object is only valid for as long as the \\'Tree\\' it was created from\\. If the tree was edited methods on the node might return wrong results\\. In this case you should retrieve the node from the tree again\\. \\'type\\_id\\' is called \\*symbol\\* in Tree\\-Sitter\\. Features not included \\(because we currently don\\'t use them\\)\\: \\- Get child by filed\\: \\- \\`ts\\_node\\_child\\_by\\_field\\_name\\` \\- \\`ts\\_node\\_child\\_by\\_field\\_id\\` \\- Get child\\/decendant for byte\\/point \\(range\\)\\: \\- \\`ts\\_node\\_first\\_child\\_for\\_byte\\` \\- \\`ts\\_node\\_first\\_named\\_child\\_for\\_byte\\` \\- \\`ts\\_node\\_descendant\\_for\\_byte\\_range\\` \\- \\`ts\\_node\\_descendant\\_for\\_point\\_range\\` \\- \\`ts\\_node\\_named\\_descendant\\_for\\_byte\\_range\\` \\- \\`ts\\_node\\_named\\_descendant\\_for\\_point\\_range\\` \\- Editing nodes directly\\: \\- \\`ts\\_node\\_edit\\`  \n\n---\n```cpp\n// In namespace ts\nclass Node {}\n```"
    },
    "range": {
        "end": {
            "character": 9,
            "line": 110
        },
        "start": {
            "character": 5,
            "line": 110
        }
    }
}

Rendered as:

2020-09-06-121335_881x513_scrot

Especially for longer text this is really distracting.

It would be better to remove the uselsss escaping (but it might be hard to detect when the escaping is really useless). Maybe an option to specify a "processor" for the markdown text would be good. Then the user can do exactly what they want and (e.g. also remove links or whatever they want).

Describe alternatives you've considered
This could also be fixed in clangd by not escaping and they have improved this a little (https://reviews.llvm.org/D75687). But I haven't tested this and I think I also saw some other issues that were complaining about the same thing for other language servers.

@fannheyward
Copy link
Member

This should be done in language server.

@chemzqm
Copy link
Member

chemzqm commented Sep 10, 2020

It should be hidden, need some work for that.

@flw-cn
Copy link

flw-cn commented Sep 13, 2020

@Lythenas 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.

@Lythenas
Copy link
Author

@flw-cn This pretty much works. But I have to set the filetype of the floating window manually and turn off all the settings I use in normal markdown (e.g. folding): :setlocal filetype=markdown signcolumn=no nofoldenable.

I think you also missed a few escapes. I spotted \, in the text. And \- in the headline.

@flw-cn
Copy link

flw-cn commented Sep 14, 2020

@Lythenas You're right, so it's still best to do some targeted customization of the floating box in the coc.

I'm thinking of sending a PR like this to enhance coc's support for floating windows by adding something like after/syntax/markdown.vim to coc. But I'm not sure if coc's main maintenancer could be considered for merge.

Also, the support in the header I will add. But is \, a valid markdown escape code? I was referencing the list given here.

I could add it to the list as well, but I don't know when that will end if I don't have a complete list.

@Lythenas
Copy link
Author

Honestly I'm not really sure what a valid markdown escape code is. I just know that clangd produces \,. But thinking about it I'm not sure if , does any formatting at all in markdown. But I found this in the spec for commonmark: There is a section about Backslash escapes and \, is listed there.

@flw-cn
Copy link

flw-cn commented Sep 14, 2020

I've added \, to the code. Please keep the discussion going if there are any gaps.

@chemzqm chemzqm added the help wanted Extra attention is needed label Oct 9, 2020
chemzqm added a commit that referenced this issue Oct 16, 2020
Make it possible to diable markdown document of language server.

Related #2308
@chemzqm
Copy link
Member

chemzqm commented Oct 23, 2020

Will rework highlights for markdown, please comment #2497

@chemzqm chemzqm closed this as completed Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants