Skip to content

Commit

Permalink
feat(cmp): incude item.detail when it's not part of item.documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 10, 2023
1 parent 208f6a8 commit c2a745a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lua/noice/lsp/override.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ function M.setup()
Hacks.on_module("cmp.entry", function(mod)
mod.get_documentation = function(self)
local item = self:get_completion_item()
if item.documentation then
return Format.format_markdown(item.documentation)

local lines = item.documentation and Format.format_markdown(item.documentation) or {}
local ret = table.concat(lines, "\n")

if item.detail and not ret:find(item.detail, 1, true) then
local ft = self.context.filetype
local dot_index = string.find(ft, "%.")
if dot_index ~= nil then
ft = string.sub(ft, 0, dot_index - 1)
end
ret = ("```%s\n%s\n```\n%s"):format(ft, vim.trim(item.detail), ret)
end
return {}
return vim.split(ret, "\n")
end
end)
end
Expand Down

0 comments on commit c2a745a

Please sign in to comment.