Skip to content

Commit 5ffd608

Browse files
committed
fix: snippets source expanding vars
1 parent fc348da commit 5ffd608

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lua/blink/cmp/sources/snippets/init.lua

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ function snippets:get_completions(_, callback)
4444
end
4545

4646
function snippets:resolve(item, callback)
47+
local parsed_snippet = require('blink.cmp.sources.snippets.utils').safe_parse(item.insertText)
48+
local snippet = parsed_snippet and tostring(parsed_snippet) or item.insertText
49+
4750
-- TODO: ideally context is passed with the filetype
48-
local documentation = '```' .. vim.bo.filetype .. '\n' .. item.insertText .. '```' .. '\n---\n' .. item.description
51+
local documentation = '```' .. vim.bo.filetype .. '\n' .. snippet .. '```' .. '\n---\n' .. item.description
4952

5053
local resolved_item = vim.deepcopy(item)
5154
resolved_item.documentation = {

lua/blink/cmp/sources/snippets/registry.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function registry:snippet_to_completion_item(snippet)
110110
kind = require('blink.cmp.types').CompletionItemKind.Snippet,
111111
label = snippet.prefix,
112112
insertTextFormat = vim.lsp.protocol.InsertTextFormat.Snippet,
113-
insertText = self:parse_body(body),
113+
insertText = self:expand_vars(body),
114114
description = snippet.description,
115115
}
116116
end

0 commit comments

Comments
 (0)