From 85f318b6db5b48d825d4ef575b405a8d41233753 Mon Sep 17 00:00:00 2001 From: Liam Dyer Date: Tue, 3 Dec 2024 16:39:56 -0500 Subject: [PATCH] fix: luasnip resolve documentation Closes #437 Co-authored-by: soifou --- lua/blink/cmp/sources/luasnip.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lua/blink/cmp/sources/luasnip.lua b/lua/blink/cmp/sources/luasnip.lua index 9ed11ed1..5126b873 100644 --- a/lua/blink/cmp/sources/luasnip.lua +++ b/lua/blink/cmp/sources/luasnip.lua @@ -95,11 +95,17 @@ function source:resolve(item, callback) local snip = require('luasnip').get_id_snippet(item.data.snip_id) local resolved_item = vim.deepcopy(item) - resolved_item.detail = snip:get_docstring() - resolved_item.documentation = { - kind = 'markdown', - value = table.concat(vim.lsp.util.convert_input_to_markdown_lines(item.data.documentation or ''), '\n'), - } + + local detail = snip:get_docstring() + if type(detail) == 'table' then detail = table.concat(detail, '\n') end + resolved_item.detail = detail + + if snip.dscr then + resolved_item.documentation = { + kind = 'markdown', + value = table.concat(vim.lsp.util.convert_input_to_markdown_lines(snip.dscr), '\n'), + } + end callback(resolved_item) end