mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
LSP: Improve the display of the default hover callback. (#11576)
Strips the code blocks from markdown and does syntax highlighting.
This commit is contained in:
@@ -68,16 +68,22 @@ M['textDocument/completion'] = function(_, _, result)
|
||||
end
|
||||
|
||||
M['textDocument/hover'] = function(_, method, result)
|
||||
util.focusable_preview(method, function()
|
||||
util.focusable_float(method, function()
|
||||
if not (result and result.contents) then
|
||||
return { 'No information available' }
|
||||
-- return { 'No information available' }
|
||||
return
|
||||
end
|
||||
local markdown_lines = util.convert_input_to_markdown_lines(result.contents)
|
||||
markdown_lines = util.trim_empty_lines(markdown_lines)
|
||||
if vim.tbl_isempty(markdown_lines) then
|
||||
return { 'No information available' }
|
||||
-- return { 'No information available' }
|
||||
return
|
||||
end
|
||||
return markdown_lines, util.try_trim_markdown_code_blocks(markdown_lines)
|
||||
local bufnr, winnr = util.fancy_floating_markdown(markdown_lines, {
|
||||
pad_left = 1; pad_right = 1;
|
||||
})
|
||||
util.close_preview_autocmd({"CursorMoved", "BufHidden", "InsertCharPre"}, winnr)
|
||||
return bufnr, winnr
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user