From 16f70ee02942e489fdf383c71d1439912ab6a008 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 20 Feb 2022 14:11:30 +0100 Subject: support hoverResults containing MarkedString[] python-language-server sends a list of MarkedStrings containing the signature as python code-block and the doc string as string. https://github.com/palantir/python-language-server/issues/836 --- init.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 19e6173..a063ac2 100644 --- a/init.lua +++ b/init.lua @@ -757,8 +757,22 @@ local function lspc_handle_hover_method_response(win, result, old_pos) local hover_header = '--- hover: ' .. (win.file.path or '') .. ':' .. sel.line .. ', ' .. sel.col .. ' ---' - -- extract the string value from a possible MarkupContent object - local hover_msg = result.contents.value or result.contents + + local hover_msg = '' + -- result is MarkedString[] + if type(result.contents) == 'table' then + lspc.log('hover returned list of length ' .. #result.contents) + for i, v in ipairs(result.contents) do + if i == 1 then + hover_msg = v.value or v + else + hover_msg = hover_msg .. '\n---\n' .. (v.value or v) + end + end + -- result is either MarkedString or MarkupContent + else + hover_msg = result.contents.value or result.contents + end vis:message(hover_header .. '\n' .. hover_msg) end -- cgit v1.2.3