fix(lsp): generate snippet preview from resolved textEdit.newText

Problem:
When a resolved `CompletionItem` with kind `Snippet` populates
`textEdit` instead of `insertText`, the contents are not previewed.

Solution:
Generate the snippet preview from `textEdit.newText` as well.
This commit is contained in:
Marcus Caisey
2026-05-12 22:38:53 +01:00
parent 89431707a0
commit 10a53e7637
2 changed files with 48 additions and 8 deletions

View File

@@ -773,9 +773,9 @@ function CompletionResolver:request(bufnr, param, selected_word)
return
end
-- generate snippet preview info
local insert_text = vim.tbl_get(result, 'insertText')
if insert_text then
value = ('```%s\n%s\n```'):format(vim.bo.filetype, parse_snippet(insert_text))
local text = vim.tbl_get(result, 'insertText') or vim.tbl_get(result, 'textEdit', 'newText')
if text then
value = ('```%s\n%s\n```'):format(vim.bo.filetype, parse_snippet(text))
kind = lsp.protocol.MarkupKind.Markdown
end
end