-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
LSP: docs/hover handler doesn't handle HTML escape sequences #22757
Comments
I also volunteer to write a PR for this, but there are a couple of questions I'd like to have answered first.
|
Is that even valid Markdown? Neovim's policy is to strictly implement the specification and not cater to every off-spec quirk that language servers may have "because VS Code handles it fine". (And the near-term goal is to replace this function with one that uses the tree-sitter Markdown parser.) |
Yes 👍
No (see above), but a small code change to workaround the issue is fine as a short-term solution, imo. |
Indeed, I don't think this is valid in "normal" markdown even though it works on github-flavored markdown and some others. I'll try to continue the discussion on the language server side to see why the returned value is like this to begin with.
nice.
Got it. Would something like this be a good, small, workaround for now? -- in function M.stylized_markdown in runtime/lua/vim/lsp/util.lua
stripped = vim.tbl_map(
function(line)
line = string.gsub(line, '>', '>')
line = string.gsub(line, '<', '<')
line = string.gsub(line, '"', '"')
line = string.gsub(line, ''', "'")
line = string.gsub(line, ' ', ' ')
line = string.gsub(line, ' ', ' ')
line = string.gsub(line, '&', '&')
return line
end,
stripped
) |
Yes, that looks fine. |
Implements neovim#22757 During handling of textDocument/hover, if the language server returns a payload containing markdown with some html escape sequences, the neovim handler will convert common ones to characters to display in the floating window's buffer. Signed-off-by: Kasama <robertoaall@gmail.com>
Implements neovim#22757 During handling of textDocument/hover, if the language server returns a payload containing markdown with some html escape sequences, the neovim handler will convert common ones to characters to display in the floating window's buffer. Signed-off-by: Kasama <robertoaall@gmail.com>
Implements neovim#22757 During handling of textDocument/hover, if the language server returns a payload containing markdown with some html escape sequences, the neovim handler will convert common ones to characters to display in the floating window's buffer. Signed-off-by: Kasama <robertoaall@gmail.com>
Implements neovim#22757 During handling of textDocument/hover, if the language server returns a payload containing markdown with some html escape sequences, the neovim handler will convert common ones to characters to display in the floating window's buffer. Signed-off-by: Kasama <robertoaall@gmail.com>
Implements neovim#22757 During handling of textDocument/hover, if the language server returns a payload containing markdown with some html escape sequences, the neovim handler will convert common ones to characters to display in the floating window's buffer. Signed-off-by: Kasama <robertoaall@gmail.com>
Implements neovim#22757 During handling of textDocument/hover, if the language server returns a payload containing markdown with some html escape sequences, the neovim handler will convert common ones to characters to display in the floating window's buffer. Signed-off-by: Kasama <robertoaall@gmail.com>
Implements neovim#22757 During handling of textDocument/hover, if the language server returns a payload containing markdown with some html escape sequences, the neovim handler will convert common ones to characters to display in the floating window's buffer. Signed-off-by: Kasama <robertoaall@gmail.com>
Problem: LSP docs hover (textDocument/hover) doesn't handle HTML escape seqs in markdown. Solution: Convert common HTML escape seqs to a nicer form, to display in the float. closees #22757 Signed-off-by: Kasama <robertoaall@gmail.com>
Problem: LSP docs hover (textDocument/hover) doesn't handle HTML escape seqs in markdown. Solution: Convert common HTML escape seqs to a nicer form, to display in the float. closees neovim#22757 Signed-off-by: Kasama <robertoaall@gmail.com>
Problem: LSP docs hover (textDocument/hover) doesn't handle HTML escape seqs in markdown. Solution: Convert common HTML escape seqs to a nicer form, to display in the float. closees neovim#22757 Signed-off-by: Kasama <robertoaall@gmail.com>
Problem
Related to this issue
When the Language server responds a markdown payload for a
textDocument/hover
request containing html escape sequences (in this example, many 
sequences), the stylize_markdown function doesn't handle it, causing it to be written as-is to the floating window's buffer.Example response:
Example hover on neovim
It would be great to have neovim decode those html sequences, similar to what this luarocks package does.
A workaround for me is to use a wrapper function around
vim.lsp.handlers.hover
to remove those sequences manuallyAdding this to init.lua fixes the appearance of the hover for this language server, but there are others that probably have similar issues.
Steps to reproduce using "nvim -u minimal_init.lua"
cd $(mktemp -d)
and create aninit.lua
file with the following contentsnvim --noplugin -u init.lua .gitlab-ci.yaml
<space>
with the cursor over the wordstages
Expected behavior
I expected neovim to be able to parse html entities in a markdown hover response to properly display them in the floating buffer.
Neovim version (nvim -v)
NVIM v0.8.3 Build type: Release
Language server name/version
yaml-language-server 1.12.0 https://github.com/redhat-developer/yaml-language-server/releases/tag/1.12.0
Operating system/version
Linux Kasama 6.2.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 18 Mar 2023 01:06:36 +0000 x86_64 GNU/Linux
Log file
No response
The text was updated successfully, but these errors were encountered: