Skip to content

Commit

Permalink
feat: fill in snippet detail if missing in LSP resolve
Browse files Browse the repository at this point in the history
Closes #976
  • Loading branch information
Saghen committed Jan 19, 2025
1 parent d0cb8e8 commit 8f27db5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lua/blink/cmp/sources/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ function lsp:resolve(item, callback)

local success, request_id = client.request('completionItem/resolve', item, function(error, resolved_item)
if error or resolved_item == nil then callback(item) end

-- Snippet with no detail, fill in the detail with the snippet
if resolved_item.detail == nil and resolved_item.insertTextFormat == vim.lsp.protocol.InsertTextFormat.Snippet then
local parsed_snippet = require('blink.cmp.sources.snippets.utils').safe_parse(item.insertText)
local snippet = parsed_snippet and tostring(parsed_snippet) or item.insertText
resolved_item.detail = snippet
end

callback(resolved_item)
end)
if not success then callback(item) end
Expand Down

0 comments on commit 8f27db5

Please sign in to comment.