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:
Ashkan Kiani
2019-12-20 02:50:37 -08:00
committed by GitHub
parent d00c624ba4
commit 026ba804d1
2 changed files with 138 additions and 12 deletions

View File

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