Skip to content

Commit

Permalink
feat: show version in labelDetails.description when completing crates
Browse files Browse the repository at this point in the history
  • Loading branch information
saecki committed Feb 7, 2025
1 parent bd35b13 commit 1d92a7f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lua/crates/completion/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ local M = {}

---@class CompletionItem
---@field label string
---@field labelDetails? CompletionItemLabelDetails
---@field detail string?
---@field kind integer? -- CompletionItemKind?
---@field deprecated boolean?
---@field sortText string?
---@field insertText string?
---@field cmp CmpCompletionExtension?

---@class CompletionItemLabelDetails
---@field detail? string
---@field description? string

---@class CmpCompletionExtension
---@field kind_text string
---@field kind_hl_group string
Expand Down Expand Up @@ -268,6 +273,9 @@ local function complete_crates(buf, prefix, line, col, crate)
local result = state.search_cache.results[r]
table.insert(results, {
label = result.name,
labelDetails = {
description = result.newest_version,
},
kind = CompletionItemKind.VALUE,
detail = table.concat({ result.newest_version, result.description }, "\n"),
textEditText = insertText(result.name, result.newest_version),
Expand Down

0 comments on commit 1d92a7f

Please sign in to comment.