Skip to content

Commit

Permalink
feat(menu): also display completion_item.detail in docs and better ch…
Browse files Browse the repository at this point in the history
…eck for empty docs

fixes #106
  • Loading branch information
max397574 committed Oct 20, 2024
1 parent b3acce0 commit ba285f9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lua/care/menu/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ function Menu:draw_docs(entry)

local function open_docs_window(doc_entry)
local config = self.config.ui.docs_view or {}
if not doc_entry.completion_item.documentation then
local completion_item = doc_entry.completion_item
if
not completion_item.documentation and not completion_item.detail
or (completion_item.documentation:match("^%s*$") and completion_item.detail:match("^%s*$"))
then
self.docs_window:close()
return
end
local documentation = doc_entry.completion_item.documentation
local documentation = completion_item.documentation
local format = "markdown"
local contents
if type(documentation) == "table" and documentation.kind == "plaintext" then
Expand All @@ -58,6 +62,10 @@ function Menu:draw_docs(entry)
contents = vim.lsp.util.convert_input_to_markdown_lines(documentation --[[@as string]])
end

if completion_item.detail and completion_item.detail ~= "" then
table.insert(contents, 1, completion_item.detail .. "\n---")
end

local menu_border = self.config.ui.menu.border
local menu_has_border = menu_border and menu_border ~= "none"

Expand Down

0 comments on commit ba285f9

Please sign in to comment.