fix(lsp): set extra info only when it has a value (#23868)

This commit is contained in:
Raphael
2023-06-05 13:17:38 +08:00
committed by GitHub
parent cc41697775
commit 3c6d971e54
2 changed files with 21 additions and 17 deletions

View File

@@ -716,15 +716,18 @@ function M.text_document_completion_list_to_complete_items(result, prefix)
local matches = {}
for _, completion_item in ipairs(items) do
local info = ' '
local info = ''
local documentation = completion_item.documentation
if documentation then
if type(documentation) == 'string' and documentation ~= '' then
info = documentation
elseif type(documentation) == 'table' and type(documentation.value) == 'string' then
info = documentation.value
-- else
-- TODO(ashkan) Validation handling here?
else
vim.notify(
('invalid documentation value %s'):format(vim.inspect(documentation)),
vim.log.levels.WARN
)
end
end
@@ -734,7 +737,7 @@ function M.text_document_completion_list_to_complete_items(result, prefix)
abbr = completion_item.label,
kind = M._get_completion_item_kind_name(completion_item.kind),
menu = completion_item.detail or '',
info = info,
info = #info > 0 and info or nil,
icase = 1,
dup = 1,
empty = 1,