From c63ec482d8dd3c5616ed8bb38ddc19fef02fd93b Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 8 Dec 2024 11:40:46 +0100 Subject: [PATCH] feat(preset_utils): add label_detail closes https://github.com/max397574/care.nvim/issues/146 --- lua/care/presets/utils.lua | 13 +++++++++++++ lua/care/types/preset_utils.lua | 3 +++ 2 files changed, 16 insertions(+) diff --git a/lua/care/presets/utils.lua b/lua/care/presets/utils.lua index 9b5023f..8a2171e 100644 --- a/lua/care/presets/utils.lua +++ b/lua/care/presets/utils.lua @@ -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 diff --git a/lua/care/types/preset_utils.lua b/lua/care/types/preset_utils.lua index 9b95a72..2750314 100644 --- a/lua/care/types/preset_utils.lua +++ b/lua/care/types/preset_utils.lua @@ -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