mirror of
https://github.com/neovim/neovim.git
synced 2025-12-05 22:22:44 +00:00
feat(lsp): render markdown in docs hover #22766
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>
This commit is contained in:
committed by
GitHub
parent
74f05a152d
commit
257d894d75
@@ -1378,6 +1378,20 @@ function M.stylize_markdown(bufnr, contents, opts)
|
||||
end
|
||||
end
|
||||
|
||||
-- Handle some common html escape sequences
|
||||
stripped = vim.tbl_map(function(line)
|
||||
local escapes = {
|
||||
['>'] = '>',
|
||||
['<'] = '<',
|
||||
['"'] = '"',
|
||||
['''] = "'",
|
||||
[' '] = ' ',
|
||||
[' '] = ' ',
|
||||
['&'] = '&',
|
||||
}
|
||||
return (string.gsub(line, '&[^ ;]+;', escapes))
|
||||
end, stripped)
|
||||
|
||||
-- Compute size of float needed to show (wrapped) lines
|
||||
opts.wrap_at = opts.wrap_at or (vim.wo['wrap'] and api.nvim_win_get_width(0))
|
||||
local width = M._make_floating_popup_size(stripped, opts)
|
||||
|
||||
Reference in New Issue
Block a user