diff options
author | kevinhwang91 <kevin.hwang@live.com> | 2022-04-06 02:32:07 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-06 03:23:04 +0800 |
commit | ec715c27d22ab336e339effe1267a34774d8d33a (patch) | |
tree | 9dbe8618c0b8a74351a05c36ac4380d7414cb04c /script/core | |
parent | e18678a58b10ada0120b4e6d4f8c332d7f16bc4a (diff) | |
download | lua-language-server-ec715c27d22ab336e339effe1267a34774d8d33a.zip |
feat(completion): use Lua code as snippet description
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/completion/completion.lua | 16 |
1 files changed, 14 insertions, 2 deletions
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 |