From ec715c27d22ab336e339effe1267a34774d8d33a Mon Sep 17 00:00:00 2001 From: kevinhwang91 Date: Wed, 6 Apr 2022 02:32:07 +0800 Subject: feat(completion): use Lua code as snippet description --- script/core/completion/completion.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'script/core') diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index 06b46de9..53a80fc3 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -1349,11 +1349,23 @@ local function pushCallEnumsAndFuncs(defs) } end if def.type == 'doc.type.function' then + local insertText = buildInsertDocFunction(def) + local description + if def.comment then + description = def.comment + else + local descText = insertText:gsub('%$%{%d+:([^}]+)%}', function (val) + return val + end):gsub('%$%{?%d+%}?', '') + description = markdown() + : add('lua', descText) + : string() + end results[#results+1] = { label = infer.viewDocFunction(def), - description = def.comment, + description = description, kind = define.CompletionItemKind.Function, - insertText = buildInsertDocFunction(def), + insertText = insertText, } end end -- cgit v1.2.3