Skip to content

Commit

Permalink
feat(preset_utils): add label_detail
Browse files Browse the repository at this point in the history
closes #146
  • Loading branch information
max397574 committed Dec 8, 2024
1 parent db69904 commit c63ec48
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lua/care/presets/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,17 @@ function PresetUtils.kind_highlight(entry, style)
return style == "fg" and ("@care.type.fg.%s"):format(entry_kind) or ("@care.type.blended.%s"):format(entry_kind)
end

function PresetUtils.get_label_detail(entry)
local label_detail = ""
if entry.completion_item.labelDetails then
if entry.completion_item.labelDetails.detail then
label_detail = label_detail .. entry.completion_item.labelDetails.detail
end
if entry.completion_item.labelDetails.description then
label_detail = label_detail .. entry.completion_item.labelDetails.description
end
end
return label_detail
end

return PresetUtils
3 changes: 3 additions & 0 deletions lua/care/types/preset_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
--- With this function you can get the kind highlight group for a specific entry. The style can either be foreground
--- or blended.
---@field kind_highlight fun(entry: care.entry, style: "fg"|"blended"): string
--- Gets the label detail if provided by the language serve.
--- This is equivalent to the `vim_item.menu` from nvim-cmp
---@field get_label_detail fun(entry: care.entry): string

0 comments on commit c63ec48

Please sign in to comment.